问题是现在我有一个设备组,其中包含两个“幽灵”注册ID,因为它们已更改,我不再知道它们是什么。
我知道当每个成员注销后,该组将被删除,但我不知道要手动注销它们的注册ID。
我该怎么办?
有没有一种方法可以检索设备组的成员或一次性删除它?
此外,管理令牌刷新的情况有什么好方法?
Sending downstream messages to device groups
Sending messages to a device group is very similar to sending messages to an individual device. Set the to parameter to the unique notification key for the device group. See Message types for details on payload support. Examples in this page show how to send data messages to device groups in HTTP and XMPP protocols.
HTTP POST Request
https://fcm.googleapis.com/fcm/send Content-Type:application/json Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA { "to": "aUniqueKey", "data": { "hello": "This is a Firebase Cloud Messaging Device Group Message!", } }
HTTP Response
Here is an example of "success"— the
notification_key
has 2 registration tokens associated with it, and the message was successfully sent to both of them:
{ "success": 2, "failure": 0 }
Here is an example of "partial success" — the
notification_key
has 3 registration tokens associated with it. The message was successfully sent to 1 of the registration tokens only. The response message lists the registration tokens that failed to receive the message:
{ "success":1, "failure":2, "failed_registration_ids":[ "regId1", "regId2" ] }
When a message fails to be delivered to one or more of the registration tokens associated with a
notification_key
, the app server should retry with backoff between retries.
然而,在进行重试之前,你可以首先验证FCM令牌是否仍然有效(可以使用dry_run
或Instance ID服务器API)。如果显示设备不再有效(通常为NotRegistered
),则应将该令牌从设备组中删除并从您的应用程序服务器中删除它(或将其移到垃圾日志中等)。
另外,有什么好方法来管理令牌刷新的情况吗?
如果令牌通过onTokenRefresh()
得到刷新,需要做的是找到用户拥有的旧令牌并用新令牌替换它,将更改应用于相关的地方(也即是映射设备组)。