Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does app give different device token on re-installing again

I remember, the device token never changes upon re-installing for iPhone.

However these days (especially on iOS 9), I noticed that device token is changing if I re-install the app.

Is this setting is done by Apple or I am missing anything?

I have to know this because this is very important for me as I am sending push based for specific users to inform their updates.

Also for no reason there are un-wanted many device tokens.

Note

I am calling below webservice in App Delegate

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
    // sending it to online database for my record
}
like image 960
Fahim Parkar Avatar asked Nov 24 '15 08:11

Fahim Parkar


People also ask

Do device tokens change iOS?

No, Device token will always be same .

What does device token mean?

The push notification networks identify each device by device token. A device token is not a device IMEI but an ID to identify a certain mobile app on a certain device. It is issued by calling libraries of FCM, JPush, or APNs.

What is device token in android?

Push token (device token) - is a unique key for the app-device combination which is issued by the Apple or Google push notification gateways. It allows gateways and push notification providers to route messages and ensure the notification is delivered only to the unique app-device combination for which it is intended.

What is device token in Apple Push Notification?

Register your app with APNs and receive a globally unique device token, which is effectively the address of your app on the current device. Your provider server must have this token before it can deliver notifications to the device.


2 Answers

Yes on iOS9 Apple says that Device Token might change each time your app is installed. So the best way is to reregister the Device token on each launch.

Here is a link to Apples documentation about changing device token

like image 141
Saheb Roy Avatar answered Oct 05 '22 07:10

Saheb Roy


You need to find your own way to track user. Here is issues with your approach and suggested vendor identifier:

  • Device push token can change at any moment. You can track this change during application launch and ask server to switch tokens, but messages which will be send till this moment on old token will be lost.
  • identifierForVendor - also very unreliable source of unique identifier, because it will change in a lot of cases.

    The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them. The value can also change when installing test builds using Xcode or when installing an app on a device using ad-hoc distribution. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.

For single device you can use Keychain as source of persistent identifier storage. You can generate for user new unique identifier (for example with NSUUID) and store it in Keychain (if not exist yet). If access group will be configured for stored item and reused with all your application - you will have access to stored unique identifier from your applications on user device. If properly configured, item in Keychain will be stored in encrypted user device backups and even will be restored on his new device.

like image 22
Serhii Mamontov Avatar answered Oct 05 '22 06:10

Serhii Mamontov