Unexpected behavior when updating a user token that is a unique member of a device group

I implemented a mapping between devices, registration IDs, and groups, as described here

Basically, a table appeared in which to store the device reg identifier and the notification key of the group in which it was registered (if any), and added two fields to my user table to track the number of devices that the user was logged into and how determined the name of the group.

Unfortunately, during testing, I showed very strange behavior when updating a user token, which is also the only member of the device group.

as explained in the comments on the question I asked here

if the previous token was the only member of the device group, after receiving the update it is invalid, but the group continues to exist, and somehow a new token is added to it. I can even successfully remove a new token from the group by deleting it, or I can notify the group to "wake up" and make it automatically deleted.

in a couple of attempts that I made right now before posting this happened:

  • get a new token let's say reg_id1
  • register reg_id1for device group test_group(creation)

to create a group:

curl --header "Authorization: your_key" 
--header Content-Type:"application/json" 
-H "project_id:your_id"   https://android.googleapis.com/gcm/notification 
-d "{ \"operation\": \"create\", \"notification_key_name\": 
\"test_group\", \"registration_ids\": [\"reg_id1\" ] }"
  1. check if group exists

with this

curl -v -H "Content-Type:application/json" -H "Authorization:key=your_key" 
-H "project_id:your_id"
https://android.googleapis.com/gcm/notification?notification_key_name=test_group
  1. update reg_id1in the way you prefer (deleting application data if on an android or requesting a new token if in a web application)
  2. , 3

( )

  1. . ? , .. , ,

curl --header "Authorization: key=your_key" 
--header Content-Type:"application/json" -H "project_id:your_id" 
https://android.googleapis.com/gcm/notification 
-d "{ \"operation\": \"remove\", \"notification_key_name\": 
\"test_group\", \"notification_key\": \"group_key\", 
\"registration_ids\": [\"reg_id1\" ] }"
  1. : ! , , ... ! ?
  2. 3 .. ?! ( , , android, .. , curl )
  3. !

curl -X POST -H "your_key" 
-H "Content-Type: application/json" 
-d '{ 
"notification": {
 "title": "Portugal vs. Denmark",
 "body": "5 to 1",
 "icon": "firebase-logo.png",
 "click_action": "http://localhost:8081"
},
"to": "group_key"
}' "https://fcm.googleapis.com/fcm/send"
  1. , 1 ( ), ping, .

, , , .

- ? Android, , , / , ( , ), ( ). , . , , . wake it up ? ? ( android )

EDIT: :

  • reg_id1,
  • reg_id1
  • , ( , )
  • , 500
  • 0 0
  • , ( )

EDIT2:

:

  • android , , .
  • - , , 0 0. , , , . , 20 ( 25 ). , -. , - , ( android) , , .
+2
1

, . , , , , .

, , :

  • android, , , , ( , / ). ( dry_run) , , , . , , , , ! , !

  • Webapp , (?). , Firefox , . , 0 0 , . , , 0 - 0 . chrome android ( ..).

- Android, -, , , , (user_id, reg_id). , , , ( ), , , . , , , chrome (), , , ( " " " " - ). , , , , , , db, . , api firebase, : .

, , ( cURL-) , , , . , , , .

( ), , , , - , , . .

, . - , , , .

+2

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


All Articles