Firebase - delete a group of devices without knowing the registration identifiers of its members

While working with Firebase and Device groups, I tested the case when the token (registration identifier) ​​changes (for example, after reinstalling the application), but my logic failed because after reinstalling the application I no longer have a way to find out the previously saved token.

The problem is that now I have a group of devices with two registration identifiers "ghost"that I no longer know because they have changed.

I know that a group is deleted after each member has been unregistered, but I do not know that registration identifiers are registered manually.

What can I do?

Is there a way to get the elements of a device group or delete them right away?

Also, what is a good way to manage a case in which a token is updated?

+6
source share
1 answer

I know that a group is deleted after each member has been unregistered, but I do not know that registration identifiers are registered manually. What can I do?

When sending a message to a group of devices, you will receive a response containing the parameters successand failure. 0The value for `fail" means that the messages that we delivered correctly on the FCM server.

These were unsuccessful messages, a list of registration response tokens that were unsuccessful will be in the response, where the board should resend the message. Referring to docs :

. . . . , HTTP XMPP.

HTTP POST

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-

"". notification_key 2 , :

{
  "success": 2,
  "failure": 0
}

" " - notification_key 3 . . , :

{
  "success":1,
  "failure":2,
  "failed_registration_ids":[
     "regId1",
     "regId2"
  ]
}

, notification_key, .

, FCM ( dry_run, API- ), , ( NotRegistered, Server ( - ).

, , ?

( onTokenRefresh()), , , , , ( ).

. . .

+5

Source: https://habr.com/ru/post/1016637/


All Articles