I'm trying to figure out how to manage FCM device groups from an app server by using the REST API.
AFAIK these are the updated docs: https://firebase.google.com/docs/cloud-messaging/android/device-group#managing_device_groups
Here's what I can already do:
- Create a new device group with some device tokens
- Add device tokens to an existing device group
And this is what I just can't figure out how to do since there's no mention of it in the docs:
Query whether a device group already exists, based on its
notification_key_name
.Workaround 1: if I try creating a group with a
notification_key_name
that already exists then I get an error telling me so, but that seems like a very hacky way to find out.Workaround 2: Store that information by myself somewhere else.
Finding out which device tokens (
registration_id
) belong to a device group.Workaround: as before, store that information by myself somewhere else.
Remove device tokens (
registration_id
) from a device group.Workaround: none.
Remove a device group.
Workaround: none.
Thanks!
Your 2nd workaround is the way to go. You should store it in your App server, same where you also store the Registration Tokens.
Same as the workaround above. You have to manage these details on your App Server. It is the developer's responsibility to manage these details. Matching the actions if the registration device is removed, you'll have to remove it from your App Server as well.
I'm not sure what you need here. The documentation have details on removing registration tokens from the device group:
From the note in the docs above:
To add another option to the first question, not sure if this was added by FCM after the accepted answer but, in the Managing device groups on the app server section in the Android (and IOS) documentation, there is a part on Retrieving a notification key using a GET request to
https://fcm.googleapis.com/fcm/notification?notification_key_name=appUser-Chris
This returns
{ "error": "notification_key not found" }
if the device group does not exist, or the notification key, otherwise.