ios 7 设备令牌对于同一设备是不同的
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19524942/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ios 7 device token is different for same device
提问by Paragon
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.
我在一台设备中有两个应用程序。对于 iOS 7,两个应用程序都发送不同的设备令牌,但对于 iOS 6,两个应用程序都发送相同的设备令牌。
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?
根据我的理解,一台设备中的所有应用程序的设备令牌必须相同。iOS7 和 iOS 6 有什么不同吗?
采纳答案by Paragon
This one was also helpful.Please see point 1 in this article: https://support.urbanairship.com/customer/portal/articles/1321513-how-ios-7-handles-push-differently
这个也很有帮助。 请参阅本文中的第 1 点:https: //support.urbanairship.com/customer/portal/articles/1321513-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."
“在 iOS 7 之前,设备令牌在给定设备上的所有应用程序安装中是相同的。手机上的不同应用程序,无论是 Tap Tap Revenge 还是 USA Today,都将使用相同的地址,即设备令牌,来路由推送通知您。您与消息配对的安全凭证将确保它发送到正确的应用程序。在 iOS 7 上,Apple 更进了一步,确保现在每个应用程序安装中的设备令牌都不同。这有助于通过删除另一个手机级标识符进一步保护用户的隐私。”
回答by Tommie C.
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.
根据您的描述,我建议 iOS6 和 iOS7 之间的令牌生成发生了根本性的变化。要更仔细地检查这种行为,我建议您查看本地和推送通知编程指南。在“调度、注册和处理通知”部分的指南中,可以找到来自 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.
设备令牌可以更改。你的应用每次启动时都需要重新注册——在 iOS 中通过调用 UIApplication 的 registerForRemoteNotificationTypes: 方法,在 OS X 中通过调用 NSApplication 的 registerForRemoteNotificationTypes: 方法。传递给此方法的参数指定应用程序希望接收的初始通知类型。用户可以随时修改启用的通知类型,使用 iOS 中的设置或 OS X 中的系统偏好设置。您可以使用 UIApplication 的 enabledRemoteNotificationTypes 属性或 NSApplication 的 enabledRemoteNotificationTypes 属性查询当前启用的通知类型。如果您的应用程序未启用这些通知类型中的任何一种,则系统不会标记图标、显示警报消息或播放警报声音,
Reference:
参考:
Apple uses device tokens when users agree to receive remote notifications from the Apple Push Service.
当用户同意从 Apple Push Service 接收远程通知时,Apple 会使用设备令牌。
Typically the device token is accessed in the following method:
通常通过以下方法访问设备令牌:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
deviceTokenA 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.
deviceToken向 APS 标识设备的令牌。令牌是一种不透明的数据类型,因为这是提供商在向设备发送通知时需要提交给 APS 服务器的表单。出于性能原因,APS 服务器需要二进制格式。
请注意,设备令牌与 UIDevice 的 uniqueIdentifier 属性不同,因为出于安全和隐私原因,它必须在擦除设备时更改。
There are also significant changes to the UIDevice Identifier (Apple has restricted usage). I would suggest the following reads:
UIDevice 标识符也有重大变化(Apple 限制使用)。我建议阅读以下内容:
回答by Bipin Khanal
Though this is very late answer, I want to share my test done for i0S 9.2.1. The device token is unique for each app in a device. A new device token will be generated each time we install an app. As far as I know, apple has changed its policy for device token after they released iOS7.
虽然这是一个很晚的答案,但我想分享我为 i0S 9.2.1 所做的测试。设备令牌对于设备中的每个应用程序都是唯一的。每次我们安装应用程序时都会生成一个新的设备令牌。据我所知,苹果在发布 iOS7 后改变了设备令牌的政策。