推送通知令牌在单个设备的所有应用程序中是否唯一?

发布于 2024-08-30 20:39:34 字数 196 浏览 2 评论 0原文

我将在应用商店上拥有多个应用程序和 1 个城市飞艇帐户,用于向所有这些设备发送推送通知。我想知道的是,每个 Apple 设备是否在所有应用程序中都具有相同的“推送令牌”?这更多的是一种数据库架构问题,因此,如果一台设备使用我的许多应用程序,我就不会多次重复推送令牌。

如果每个 Apple 设备为其安装的每个应用程序生成一个唯一的推送令牌,那么我的架构需要更改。

I will have multiple applications on the app store and 1 urban airship account to send push notifications to all of these devices. What I want to know is if each Apple device has the same "push token" across all applications? This is more of a database architecture thing so that I don't duplicate a push token many times if one single device uses many of my apps.

If each Apple device generates a unique push token for each application it has installed my architecture needs to change.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

知你几分 2024-09-06 20:39:34

每个设备的设备令牌并不完全是唯一的;它们对于每个操作系统安装都是唯一的。因此,如果用户购买新设备但不从备份恢复,那么他们将获得新的设备令牌。如果设备被擦除,它将获得新的设备令牌,因此新用户不会收到旧用户的消息。

此外,使用沙箱的开发应用程序和使用生产系统的分发应用程序会返回不同的令牌。

由于单个用户可能将您的应用程序合法地安装在多个设备上(例如 iPhone 和 iPad),因此为了安全起见,在用户和设备令牌之间建立多对多关系会更安全。

既然您提到了城市飞艇,您可能会发现我们的别名功能有助于解决此类问题;您可以为我们的不同令牌分配一个非唯一的别名,然后我们将跟踪您的用户与其设备令牌之间的映射。请参阅UA 文档的注册和推送部分。

编辑:更新,因为我看到这个旧答案有更多的赞成票。从 iOS 7 开始,每个应用程序的设备令牌都是唯一的,即使在同一设备上也是如此。

Device tokens are not exactly unique per device; they're unique per operating system installation. So if a user buys a new device but does not restore from backup, then they'll get a new device token. And if a device is wiped, it will get a new device token, so the new user doesn't get the old user's messages.

In addition, there are different tokens returned for development apps using the sandbox and distribution apps using the production system.

Since a single user might have your app installed on multiple devices legally (iPhone and iPad, for instance), it will be much safer to have a many to many relationship between users and device tokens, to be on the safe side.

And since you mentioned Urban Airship, you might find that our alias feature helps for this sort of thing; you can assign a non-unique alias to the different tokens in our end, and then we'll keep track of the mapping between your users and their device tokens. See the registration and push parts of the UA documentation.

Edit: An update because I saw some more upvotes on this old answer. As of iOS 7, device tokens are unique for each application, even on the same device.

一抹微笑 2024-09-06 20:39:34

根据苹果最新文档:

切勿在您的应用中缓存设备令牌;相反,当您需要它们时从系统中获取它们。当某些事件发生时,APN 会向您的应用程序发出新的设备令牌。设备令牌保证不同,例如,当用户从备份恢复设备时、当用户在新设备上安装您的应用程序时以及当用户重新安装操作系统时。获取令牌(而不是依赖缓存)可确保您拥有提供商与 APN 通信所需的当前设备令牌。当您尝试获取设备令牌但它未更改时,fetch 方法会快速返回。
有关更多信息,请查看苹果文档

According to apple latest doc:

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.
For more info check apple doc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文