iOS Chat SDK v2 Push token deleting | Community
Skip to main content

iOS Chat SDK v2 Push token deleting

  • November 8, 2021
  • 8 replies
  • 0 views

Evgenii11

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?

8 replies

Eric27
  • November 8, 2021
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?

Evgenii11
  • Author
  • November 8, 2021

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.


Eric27
  • November 8, 2021
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()
 
    }
   

Evgenii11
  • Author
  • November 10, 2021

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()
}

Evgenii11
  • Author
  • November 19, 2021

Any updates?


Eric27
  • November 19, 2021
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?

 

Evgenii11
  • Author
  • November 20, 2021

Sure.


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