Is the APN Device Token unique to each individual app?

前端 未结 6 1887
名媛妹妹
名媛妹妹 2020-12-12 10:50

I have two apps on the iTunes store - both implement push notifications. While I was testing sending notifications to these production apps, I noticed that a push intended

相关标签:
6条回答
  • 2020-12-12 11:04

    NOTE: this is an old answer that is true only for iOS <= 6. See user1641761's answer for the current approach.

    Figured it out. The Device Tokens are NOT unique to the phone-app pairing. They are unique to the phone only. If you have multiple apps with push on the same phone they will all use the same Device Token. The certificate you use to send the notification will dictate which app it goes to.

    0 讨论(0)
  • 2020-12-12 11:05

    Device token for push notification is app-specific. Not device specific. i.e Device token will be different and unique for multiple apps in same device.

    According to apple,

    By supporting remote notifications you can provide up-to-date information to users of your app, even when the app is not running. To be able to receive and handle remote notifications, your app must:

    • Enable remote notifications.

    • Register with Apple Push Notification service (APNs) and receive an app-specific device token.

    • Send the device token to your notification provider server.

    • Implement support for handling incoming remote notifications.

    An app-specific device token is globally unique and identifies one app-device combination. Upon receiving a device token from APNs in your app, it is your responsibility to open a network connection to your provider. It is also your responsibility, in your app, to then forward the device token along with any other relevant data you want to send to the provider. When the provider later sends remote notification requests to APNs, it must include the device token, along with the notification payload. For more on this, see APNs Overview.

    Never cache device tokens in your app; instead, get them from the system when you need them. APNs issues a new device token to your app when certain events happen. The device token is guaranteed to be different, for example, when a user restores a device from a backup, when the user installs your app on a new device, and when the user reinstalls the operating system. Fetching the token, rather than relying on a cache, ensures that you have the current device token needed for your provider to communicate with APNs. When you attempt to fetch a device token but it has not changed, the fetch method returns quickly.

    You can refer apple document here Local and Remote Notification Programming Guide

    0 讨论(0)
  • 2020-12-12 11:15

    iOS 7 handle this differently. It is UNIQUE now.

    Please see point 1 in this article: http://urbanairship.com/blog/2013/10/03/how-ios-7-handles-push-differently

    "Prior to iOS 7, the device token was the same across all app installations on a given device. Different apps on your phone, whether Tap Tap Revenge or USA Today, would utilize the same address, i.e., device token, to route the push notification to you. The security credentials that you pair with a message would ensure it made it to the right app. On iOS 7, Apple has gone one step further and made sure that device tokens are now different in every single app install. This helps further protect users’ privacy by removing another phone-level identifier."

    See also ios 7 device token is different for same device

    0 讨论(0)
  • 2020-12-12 11:16

    That said, remember that Apple reserves the right to change a devices APNToken as they see fit, so don't use it to uniquely identify a device / user.

    0 讨论(0)
  • 2020-12-12 11:23

    Sharing my understanding and few answers from Apple Developers:

    • Device Token
      • Device token is the unique identifier of the device.
      • APNs generates device token using the unique device certificate (may be using provisioning profile)
      • Device token may be changed. So make sure you send the updated device token to your server each time.
      • Device token is SAME for all apps on the device.
      • It is device-specific and not app-specific.
      • Device Token may be different for sandbox and production.
        • Based on provisioning profile(sandbox or production), APNs may generate different device token for sandbox and production for the same device.
      • Then, how the push notification is differentiated on device? For which app it is?
        • It does it based on the app identifier and SSL certificate installed on server (using which the notification is pushed to APNs server).
    • References
      • https://devforums.apple.com/message/546592#546592
      • https://devforums.apple.com/message/134284#134284
    0 讨论(0)
  • 2020-12-12 11:23

    You can not use token as a unique identifier but remove old token using save in keygen(help from itunes) and delete old token and add new one in your database.

    0 讨论(0)
提交回复
热议问题