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_id1
for 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\" ] }"
- 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
- update
reg_id1
in the way you prefer (deleting application data if on an android or requesting a new token if in a web application) - , 3
( )
- . ? , .. , ,
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\" ] }"
- : ! , , ... ! ?
- 3 .. ?! ( , , android, .. , curl )
- !
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 ( ), ping, .
, , , .
- ?
Android, , , / , ( , ), ( ).
, .
, , . wake it up
?
? ( android )
EDIT:
:
- reg_id1,
- reg_id1
- , ( , )
- , 500
- 0 0
- , ( )
EDIT2:
:
- android , , .
- - , , 0 0. , , , . , 20 ( 25 ).
, -. , - , ( android) , , .