推送通知:关联的设备令牌设备 [英] Push Notifications: Associating a device token with a device

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

问题描述

我的应用程序目前正在接受与该previous应用程序的用户帐户相关联的推送通知,当这种情况发生时:

My app is currently receiving push notifications that are associated with the previous application user account when this type of situation occurs:


  1. 玩家安装的应用程序并注册为鲍勃

  2. Bob的设备令牌的Web服务注册

  3. 播放器重新安装应用程序,并注册为菲尔(同一台设备上)

  4. 菲尔的设备令牌的Web服务注册

虽然玩家现在登录为菲尔,他们将继续收到推送通知与鲍勃,以及菲尔关联的帐户。

Even though the player is now logged in as "phil" they will continue to receive push notifications for the account associated with "bob" as well as "phil".

如果我使用UDID我可以保证只有一个设备令牌每台设备注册,因此从玩家的旧的Web服务帐户,鲍勃移除UDID和设备令牌,从而保证每台设备只有一个活动帐户。当玩家为菲尔注册,并在Web服务器可以看到玩家已经注册使用相同的UDID一个新帐户,然后从任何旧账与UDID移除UDID和设备令牌(即鲍勃会发生这种情况帐户)。直到有人登录到该帐户再次(在同一设备或新的),没有更多的推送通知将被发送到鲍勃帐户。

If I was using UDID I could ensure that only one device token is registered per device and therefore remove the UDID and device token from the player's old web service account, "bob", thus ensuring only one active account per device. This would happen when the player registers as "phil" and the web server could see that the player has registered a new account with the same UDID and then remove the UDID and device token from any old accounts with that UDID (i.e. the "bob" account). No more push notifications would be sent to the bob account until someone logs into that account again (on the same device, or a new one).

然而,这将不能很好地工作使用CFUDIDCreate时,因为这很可能安装之间切换。

However, this is won't work very well when using CFUDIDCreate since it is likely to change between installs.

我如何确保推送通知只接收在当前登录用户的?或者,换一种方式,我怎么保证我的Web服务器存储每台设备只有一台设备令牌?

How do I ensure that push notifications are only received for the currently logged in user? Or, to put it another way, how do I ensure that my web server stores only one device token per device?

推荐答案

您可以使APNS令牌中的密钥服务器端,而不是设备特定的标识符。当重新安装应用程序,你将取代现有的(APNS的道理,鲍勃),由(APNS令牌,菲尔),从而重新安装应用程序时取出令牌和Bob的账户之间的联系。记录

You could make the APNS token the key server-side instead of a device specific identifier. When reinstalling the app, you would replace the existing (APNS token, "bob") record by (APNS token, "phil"), thus removing the link between the token and bob's account when reinstalling the app.

据我所知APNS令牌不应用程序的重新安装之间进行切换,所以这应该工作。 (如果它重新安装之间的iOS的未来版本的变化,这将不会是一个问题,因为旧的令牌将不再有效,因此该设备将不会收到通知发送到BOB)。

As far as I know the APNS token does not change between reinstalls of an app, so this should work. (If it did change between reinstalls in a future version of iOS, this would not be a problem because the old token would not be valid anymore, so the device would not get notifications sent to bob).

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

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