简体   繁体   English

存储多对令牌/设备用于推送通知

[英]Store multiple pair token/device for push notifications

I'm working on a new app and I want to give the possibility to my user to use more then one device. 我正在开发一个新应用,因此我希望用户可以使用一个以上的设备。 The app can receive push notification, my question is how to save more device/token for each user, this for send push notification to all the user's devices. 该应用程序可以接收推送通知,我的问题是如何为每个用户保存更多设备/令牌,以便将推送通知发送到所有用户的设备。

My idea is to retrive "some device ID" and then store a id/token for each device but I don't know which device ID I can use... 我的想法是检索“某些设备ID”,然后为每个设备存储一个ID /令牌,但我不知道我可以使用哪个设备ID ...

Another idea is to create a random id the first time and then send this id with token, this work (partially) until the user clear application data...in this case I need to resend a new id (no problem) but I can't know if I can remove the old id/token 另一个想法是第一次创建一个随机ID,然后将此ID与令牌一起发送(部分工作),直到用户清除应用程序数据为止。在这种情况下,我需要重新发送一个新ID(没问题),但是我可以不知道我是否可以删除旧的ID /令牌

any solution? 有什么办法吗?

You don't need "some device ID"; 您不需要“某些设备ID”; the push token is the device ID. 推送令牌设备ID。 You need to ensure that your backend database can associate more than one push token with a given user account. 您需要确保后端数据库可以将多个推送令牌与给定的用户帐户关联。 This is typically through a one->many relationship between user "users" table and your "installations" table. 这通常是通过用户“用户”表和“安装”表之间的一对多关系来实现的。

You can't rely on your app to tell your backend to remove an old token, since the user may simply delete your app and it doesn't get a chance to communicate with your back-end. 您不能依靠您的应用程序告诉您的后端删除旧令牌,因为用户可能只是删除您的应用程序,并且没有机会与您的后端进行通信。

The APNS service will deliver feedback as to which push tokens were invalid (I assume that the equivalent Android service also has something like this). APNS服务将提供有关哪些推送令牌无效的反馈(我假设等效的Android服务也有类似的内容)。 You use this feedback to purge invalid installations from your installations table. 您可以使用此反馈从安装表中清除无效的安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM