Recent searches


No recent searches

iOS Chat SDK v2 Push token deleting



Posted Nov 08, 2021

Hello 
If there any functionality to remove push token for iOS device that was previous registered?
Problem here is that when user logged out from our app can still receive push notifications.
I've found this method https://zendesk.github.io/mobile_sdk_iOS_jazzy_docs/Classes/PushNotificationsProvider.html#/c:@CM@ChatProvidersSDK@objc(cs)ZDKPushNotificationsProvider(im)unregisterPushToken 
but it doesn't work.
Could you help me with this?


0

8

8 comments

image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey Evgenii,

Would you be able to provide the relevant code snippets so that we can see how you are logging users out along with using the unregisterPushToken method?

0


So I tried 2 approaches:

1) Registering token by calling Chat.registerPushToken(deviceToken) and deleting by calling Chat.pushNotificationsProvider?.unregisterPushToken()
2) Registering token by calling Chat.pushNotificationsProvider?.registerPushToken(deviceToken) 
and deleting like in previous.
But had no luck with both cases.

0


image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey Evgenii,
 
It's tough to say without seeing the actual snippets to get a complete understanding. Though I'd try something like:
 
// Registering the push token
    func registerPushToken(_ deviceToken: Data) {
//        unregisterPushToken()
        Chat.registerPushToken(deviceToken)
    }
 // unregistering the push token, resetting the cache to prevent logout issues   
    func unregisterPushToken() {
        Chat.instance?.pushNotificationsProvider.unregisterPushToken()
        Chat.instance?.providers.chatProvider.endChat()
        Chat.instance?.resetIdentity(nil)
        Chat.instance?.clearCache()
 
    }
   

0


Hello 
I've tried this methods and still receiving pushes after calling unregisterToken

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    Chat.registerPushToken(deviceToken)
}
private func unregisterZendeskToken() {
Chat.pushNotificationsProvider?.unregisterPushToken()
    Chat.chatProvider?.endChat()
    Chat.instance?.resetIdentity(nil)
    Chat.instance?.clearCache()
}

0


Any updates?

0


image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey Evgenii,

Apologies, I didn't get notified of your update. Do you mind if I move this into a ticket so we can dig into it deeper?

 

0


Sure.

0


image avatar

Eric Nelson

Zendesk Developer Advocacy

Thanks Evgenii, I've opened up a ticket on your behalf. Look forward to working with you via that. 

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post