Firebase Cloud Messaging: Notification_key is not valid when deleting one device among many

I played with adding and removing device tokens from the FCM device group, and I noticed that if I remove the device from the group, and even if another device exists in this group, FCM cancels notification_key(detected by reusing the same key to add a new devices). This is very bad for me, because it means I cannot add new devices to the same group from which the device was deleted, and others still exist .

Here is the verification code (please fill in the appropriate values):

1. Create a device group with one device.

curl -X POST \
  https://android.googleapis.com/gcm/notification \
  -H 'authorization: key=YOUR_KEY' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'project_id: YOUR_PROJECT_ID' \
  -d '{
   "operation": "create",
   "notification_key_name": "some-group-identifier",
   "registration_ids": ["device-token-1"]
}'

, , .

{
  "notification_key": "my-new-notification-key"
}

2. .

curl -X POST \
  https://android.googleapis.com/gcm/notification \
  -H 'authorization: key=YOUR_KEY' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'project_id: YOUR_PROJECT_ID' \
  -d '{
   "operation": "add",
   "notification_key_name": "some-group-identifier",
   "notification_key": "my-new-notification-key",
   "registration_ids": ["device-token-2"]
}'

(1).

3. .

curl -X POST \
  https://android.googleapis.com/gcm/notification \
  -H 'authorization: key=YOUR_KEY' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'project_id: YOUR_PROJECT_ID' \
  -d '{
   "operation": "remove",
   "notification_key_name": "some-group-identifier",
   "notification_key": "my-new-notification-key",
   "registration_ids": ["device-token-2"]
}'

. , (1) (2).

4. .

curl -X POST \
  https://android.googleapis.com/gcm/notification \
  -H 'authorization: key=YOUR_KEY' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'project_id: YOUR_PROJECT_ID' \
  -d '{
   "operation": "add",
   "notification_key_name": "some-group-identifier",
   "notification_key": "my-new-notification-key",
   "registration_ids": ["device-token-3"]
}'

FAIL. 400, {"error": "notification_key not found"}. , ? ?

+3
1

, registration_ids, , -, -, , .

THREE chrome extensions registration_id FCM . .

@MaX .

0

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


All Articles