Is the device token as unique as the device ID?
Asked Answered
H

2

20

If we reset an iPhone, the device ID remains the same. Is it the same for the device token?

Haematoma answered 3/8, 2011 at 13:14 Comment(4)
Have a look at [this question on SO][1] [1]: #3726607Assault
generally, UDID shouldn't be used for any purpose, so that's when token comes in handy.Assault
but if somebody reset it's iPhone, will the device token change ? Or is it generated by apple from the UDID ?Haematoma
I've never considered it, but if it is the same as UDID, than it probably shouldn't change.Assault
G
22

I assume you are referring to the device token available to methods such as

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

If this is the case, then no, the device token can and will change.

Quoted from Apples Local and Push Notification Programming Guide

By requesting the device token and passing it to the provider every time your application launches, you help to ensure that the provider has the current token for the device. If a user restores a backup to a device other than the one that the backup was created for (for example, the user migrates data to a new device), he or she must launch the application at least once for it to receive notifications again. If the user restores backup data to a new device or reinstalls the operating system, the device token changes. Moreover, never cache a device token and give that to your provider; always get the token from the system whenever you need it

I can also verify this behaviour as I use Urban Airship as my notification provider and even though I have only ever used a single test device so far, there are numerous device tokens registered with my account.

Gausman answered 3/8, 2011 at 14:20 Comment(2)
"never cache a device token and give that to your provider; always get the token from the system whenever you need it", the thing is, where do you get the device token. you have to store it locally and check whether the token is different from the original one (Rayswenderich use this method in his tutorial.Kelda
That quote is taken directly from Apple's Local and Push Notification Programming Guide. There's absolutely no need to cache the token; you simply ask Apple for it on each launch of your app, and then send that onto your push provider.Gausman
L
1

Device token is unique id but will be change.

Lafleur answered 5/3, 2015 at 10:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.