ios 7 device token is different for same device

Paragon picture Paragon · Oct 22, 2013 · Viewed 25.9k times · Source

I have two applications in one device. For iOS 7 both applications are sending different device tokens but for iOS 6 both apps are sending same device token.

As per my understanding device token has to be same for all the application in one device. Is there something different in iOS7 than iOS 6?

Answer

Tommie C. picture Tommie C. · Oct 22, 2013

UPDATE:

I guess I read this one a bit too quickly. Please note my revisions. If the answer meets your use-case please feel free to accept it.

Based on your description I would suggest that there have been underlying changes to the token generation between iOS6 and iOS7. To examine this behavior more closely I recommend that you take a look at the Local and Push Notifications Programming Guide. Within the Guide in the section for "Scheduling, Registering, and Handling Notifications," one will find this statement from Apple.

Device tokens can change. Your app needs to reregister every time it is launched—in iOS by calling the registerForRemoteNotificationTypes: method of UIApplication, and in OS X by calling the registerForRemoteNotificationTypes: method of NSApplication. The parameter passed to this method specifies the initial types of notifications that the application wishes to receive. Users can modify the enabled notification types at any point, using Settings in iOS or System Preferences in OS X. You can query the currently enabled notification types using the enabledRemoteNotificationTypes property of UIApplication or the enabledRemoteNotificationTypes property of NSApplication. The system does not badge icons, display alert messages, or play alert sounds if any of these notifications types are not enabled for your app, even if they are specified in the notification payload.

Reference:

Apple uses device tokens when users agree to receive remote notifications from the Apple Push Service.

Typically the device token is accessed in the following method:

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

deviceToken A token that identifies the device to APS. The token is an opaque data type because that is the form that the provider needs to submit to the APS servers when it sends a notification to a device. The APS servers require a binary format for performance reasons.

Note that the device token is different from the uniqueIdentifier property of UIDevice because, for security and privacy reasons, it must change when the device is wiped.

Device Tokens Used in the Apple Push Notification Service

There are also significant changes to the UIDevice Identifier (Apple has restricted usage). I would suggest the following reads: