The application adds a different device token when reinstalling

I remember the device’s marker never changes when reinstalling for the iPhone.

However, these days (especially on iOS 9), I noticed that the device’s token changes if I reinstall the application.

Is this option Apple or am I missing something?

I need to know this because it is very important for me, as I send push based on specific users to inform about their updates.

In addition, for no reason there are unnecessary device tokens.

Note

I call below webservice in App Delegate

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken { // sending it to online database for my record } 
+5
source share
4 answers

Yes, on iOS9, Apple says that the device’s token can change every time your application is installed. Thus, the best way is to re-register the device token at each launch .

Here is a link to the apple documentation about changing the device token

+6
source

You need to find your own way of tracking the user. Here are the problems with your approach and the proposed vendor identifier:

  • The push token device can change at any time. You can track this change during the launch of the application and request a server to switch tokens, but messages that will be sent to this old token will be lost.
  • identifierForVendor is also a very unreliable source of a unique identifier, because it will change in many cases.

    The value in this property remains unchanged while the application (or another application from the same provider) is installed on the iOS device. The value changes when the user uninstalls all applications of these providers from the device and then reinstalls one or more of them. The value may also change when installing test builds using Xcode or when installing an application on a device using an ad-hoc distribution. Therefore, if your application stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.

For a single device, you can use Keychain as a persistent identifier repository source. You can generate a new unique identifier for the user (for example, with an NSUUID ) and save it in Keychain (if it does not already exist). If the access group is configured for the saved item and reused with your entire application, you will have access to the stored unique identifier from your applications on the user device. With proper configuration, the item in Keychain will be stored in encrypted backups of the user device and will even be restored to its new device.

+1
source

RTFM: "The value of this property is the same for applications that belong to the same vendor running on the same device. A different value is returned for applications on the same device as those of different vendors, as well as for applications on different devices regardless of vendor. "

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor

0
source

Yes, it can be changed every time you install the application. you need to update device_token every time you start the application.

0
source

Source: https://habr.com/ru/post/1236683/


All Articles