Apple 推送通知提供程序的设备令牌 [英] device tokens for Apple Push Notifications provider

查看:28
本文介绍了Apple 推送通知提供程序的设备令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我是 多个 iOS 应用程序的 Apple 推送通知提供者",我可以为多个应用程序使用相同的设备令牌吗?我知道每个应用程序都需要唯一的 SSL 证书.但是我对设备令牌感到困惑.

If I'm an Apple Push Notification "provider" for multiple iOS apps can I use the same device token for multiple apps? I'm aware that I need unique SSL certificates for each app. However I'm confused about the device tokens.

示例:我有两个应用 A 和 B.我想为这两个应用提供推送通知.假设我从安装应用程序 A 的用户那里收集了一个设备令牌 T.假设我有两个应用程序的唯一 SSL 证书.当同一用户安装应用 B 时,我可以在为应用 B 提供推送通知时重新使用令牌 T 吗?

Example: I have two apps A and B. I want to provide push notifications for both apps. Say I collect a device token T from a user who installs app A. Assume I have unique SSL certificates for both apps. When the same user installs app B can I re-use token T when providing push notifications for app B?

更多信息:重新阅读Apple 的文档 目前还不清楚.这一段似乎特别暗示设备令牌可以重复使用:

More info: After re-reading Apple's docs it's still not clear. This paragraph in particular seems to imply the device token can be re-used:

提供者发送到 APN 以传送到设备的每个通知都必须附有它从该设备上的应用程序获取的设备令牌.APNs 使用令牌密钥解密令牌,从而确保通知有效.然后它使用设备令牌中包含的设备 ID 来确定通知的目标设备.

Every notification that a provider sends to APNs for delivery to a device must be accompanied by the device token it obtained from an application on that device. APNs decrypts the token using the token key, thereby ensuring that the notification is valid. It then uses the device ID contained in the device token to determine the destination device for the notification.

注意:听起来像是每个应用的提供商 SSL 证书中包含的主题"/bundleID 将通知定向到设备上的特定应用.因此,设备令牌对于设备(而不是设备上的应用)是唯一的,这似乎是合理的.

Note: Sounds like the "topic"/bundleID contained in the provider's SSL certificate for each app directs the notifications to a particular app on a device. So it seems plausible that device tokens are unique for a device (and not for apps on the device).

推荐答案

对于两个应用程序 A 和 B,沙箱 ssl 证书的设备令牌将相同,但它会因分发配置文件而改变(即,当使用生产 ssl 证书时)

For the two apps A and B the device token will be the same for sandbox ssl certificate, but it will change for distribution profile (i.e when using production ssl certificate)

此外,当您升级操作系统时,设备令牌可能会发生变化

Also, the device tokens might change when you upgrade the OS

我也开发了一个提供者",我更喜欢为每个应用存储设备令牌.即(APP_A => Token1;APP_B => Token1)每次设备向提供者发送注册请求时,检查表中是否存在APP和设备令牌的组合,如果不存在则重新插入.

I too have developed a "provider" and I prefer to store device tokens per app. i.e (APP_A => Token1; APP_B => Token1) Everytime a device sends a registration request to the provider, check if the combination of the APP and device token exists in the table, if not do a new insert.

这样即使设备令牌因某种原因发生变化,您也不必担心.

This way you don't have to worry even if the device token changes for some reason.

这篇关于Apple 推送通知提供程序的设备令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆