iOS 中的每个应用程序是否都具有相同的 deviceToken?

Does every apps in iOS has the same deviceToken?

google后的问题,搞得我一头雾水。 iOS 中的每个应用都具有相同的 DeviceToken 吗?

这是关于这个问题的Apple Document

A device token is an opaque NSData instance that contains a unique identifier assigned by Apple to a specific app on a specific device. Only APNs can decode and read the contents of a device token. Each app instance receives its unique device token when it registers with APNs, and must then forward the token to its provider, as described in Configuring Remote Notification Support. The provider must include the device token in each push notification request that targets the associated device; APNs uses the device token to ensure the notification is delivered only to the unique app-device combination for which it is intended.

不,每个应用程序都会获得自己的设备令牌。

另请注意,分配给 app/device 的设备令牌可以而且确实会不时更改,这就是为什么您始终需要将更新版本发送到推送服务器 and/or 任何其他服务的原因可能会使用设备令牌。


关于设备令牌更改的一些说明 "from time to time":

"from time to time"的意思是"sometimes, but not regularly"

取自 Apple Documentation:

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.

每个应用程序都有不同的设备令牌。

A device token 是 iOS 设备的 Apple 推送通知系统的标识符。 Apple 在 per-app 基础上(iOS 7 及更高版本)分配设备令牌,用作发送推送通知的唯一标识符。每个设备的每个应用程序都有两个设备令牌:一个用于开发,一个用于生产(临时或应用程序商店构建)。令牌是 64 个十六进制字符。

每个应用程序实例在向 APNs 注册时都会收到其唯一的设备令牌。

每个应用程序都有不同的设备令牌。这将在您注册推送通知时生成。

如果您重新安装应用程序,那么对于同一设备上的同一应用程序,您也会获得不同的设备令牌。