1

I'm making use of push notifications in my iOS app, and it is an app which requires users to log in to access, so of course there is a logout function as well. I'd like to know if it is a good practice, or if it is the common thing to do, to "clear" the device token sent to your provider when a user logs out (I mean, to send an empty string as the device token).

Thanks in advance

AppsDev
  • 12,319
  • 23
  • 93
  • 186
  • Instead of sending empty device token ,Your logout service should set flag against current user and device token to disable pushnotifications because in case of empty device token you would not have device token on login. Device token is only obtained when app is launched (App delegate.m is loaded) – Muhammad Adnan Jun 17 '14 at 13:17
  • I store the device token whenever `- application:didRegisterForRemoteNotificationsWithDeviceToken:` is called, so I can send it when user logs in... but maybe your approach is better – AppsDev Jun 17 '14 at 13:32
  • if you set it empty. There will be no way to get it back after login unless you relaunch application – Muhammad Adnan Jun 17 '14 at 13:33
  • I meant to send an empty string just to the provider, but I keep the device token in my app – AppsDev Jun 17 '14 at 13:34
  • ok then its same as setting flag on webend. Your approach is fine – Muhammad Adnan Jun 17 '14 at 13:37

1 Answers1

3

1) Send empty String to Provider and keep device token saved locally to access on Login.

OR

2) Your logout service should set flag against current user and device token to disable pushnotifications and enable on login again.

Muhammad Adnan
  • 2,668
  • 15
  • 27
  • Beyond the fact of this approaches being ok... is it actually a usual thing to clear the token at provider side when a user logs out? – AppsDev Jun 17 '14 at 13:54
  • Yes to avoid sending Push notification when user is logged out or when user wants to no more receive push notifications (if user can enable disable push notifications). – Muhammad Adnan Jun 17 '14 at 14:03