微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 在哪个移动平台上“推送令牌”不是永久性的?

我们都知道,为了在任何移动平台中使用推送通知功能,我们需要一个名为“推送令牌”的唯一标识符.

开发人员需要以某种方式将此“令牌”保存到他的服务器,以便能够向用户发送通知.

然而,在哪个移动平台中,这个“令牌”将保持永久性并且可能会改变?

换句话说,在哪些情况下,如果发生变化,开发人员必须注意更新数据库中的用户“令牌”?

答案应包括:iOS,android,WP,BB平台.

*如果您知道这些平台中至少有一个答案会发布您的答案,最后我会总结所有答案以获得完整答案.*

解决方法:

令牌永远不会永久.

在iOS中,设备令牌对于设备上的所有应用程序都是相同的.实际上,在升级iOS版本或从备份恢复设备之前,它保持不变.从理论上讲,Apple说它可能会随时改变,所以你应该处理这个案子.

By requesting the device token and passing it to the provider every
time your application launches, you help to ensure that the provider
has the current token for the device. If a user restores a backup to a
device or computer other than the one that the backup was created for
(for example, the user migrates data to a new device or computer), he
or she must launch the application at least once for it to receive
notifications again. If the user restores backup data to a new device
or computer, or reinstalls the operating system, the device token
changes. Moreover, never cache a device token and give that to your
provider; always get the token from the system whenever you need it.
If your application has prevIoUsly registered, calling
registerForRemoteNotificationTypes: results in the operating system
passing the device token to the delegate immediately without incurring
additional overhead.

Android中,同一设备上的每个应用程序的注册ID都不同.当您从GCM取消注册您的应用程序然后重新注册它时,它有时会发生变化.但是,旧的注册ID通常用于向应用程序发送GCM消息(在这种情况下,您将在响应中获得规范的注册ID,要求您使用最新的注册ID).也就是说,Google还声称注册ID可能随时更改,因此您应该处理此案例.

Note that Google may periodically refresh the registration ID, so you
should design your Android application with the understanding that the
com.google.android.c2dm.intent.REGISTRATION intent may be called
multiple times. Your Android application needs to be able to respond
accordingly.

The registration ID lasts until the Android application explicitly
unregisters itself, or until Google refreshes the registration ID for
your Android application.

在Windows Phone中,我不确定通知通道URI在实践中的变化频率,但微软也声称它可能随时更改.

All apps should register for the ChannelUriUpdated event in case the
push notification URI changes. Even if you already have a channel
opened, you should register for the ChannelUriUpdated event in case
the URI changes.

总而言之,您应始终将令牌视为可能在您重新启动应用程序时更改.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐