Why registering for push notifications every time a user launch an app?

In the Apple documentation you can find the following sentence :

An application should register every time it launches and give its provider the current token. It calls registerForRemoteNotificationTypes: to kick off the registration process.

  • Objective C find caller of method
  • How to download CSV file from server in Objective-C
  • How to create an ANE that will natively display a Floating Window
  • iOS Multi peer connectivity showing same device name twice
  • “Apps that include an arm64 are required to include to include both armv7 and armv7s architecture” Error in application loader
  • Sound not playing with AVAudioPlayer
  • So when I implemented the push notification in my app I had to register the device, and I did what they said in that documentation: registering every time a user launch my app.
    The token that I receive from the APNS is always the same for a given user.

    My question is: why do I need to register everytime if the APNS gives me always the same token?

    I read somewhere than a token can change if a user swipe his iPhone or the app. Is it the only case?

    Thank you !

    Solutions Collect From Internet About “Why registering for push notifications every time a user launch an app?”

    The token that I receive from the APNS is always the same for a given user.

    Except it isn’t, basically because there’s nothing you can hang onto as being “a user” in the iPhone setup. The device token is always the same for each app for each device. So different apps on the same device get different tokens. The same app on two different devices gets two different tokens.

    The crucial thing to note, and this is mentioned in the APNS guide, is that a user may back up their apps, settings, everything. Then they can drop their phone down the toilet. When they get their replacement phone, they can take their backup and restore it onto their new phone. Bingo – same app, same user, different device, and different token.

    As far as your app is concerned, nothing has changed since the last time it ran – it doesn’t know that it’s actually running on a different device now. The only way it knows is because it asks for the ‘current’ device token, and hey presto it’s a different token to last time.

    You can choose to cache the token and check it against the token you just received (e.g. save it in your NSUserDefaults) – that way you don’t have to communicate it back to the server unless it has changed since the last run, but you absolutely do have to check, otherwise your users will come complaining that they don’t get push notifications any more since they replaced their phone.