I am trying to send FCN messages to a closed user group using the HTTP v1 protocol.
Note: By my definition a "closed user group" is a group that users can not enter themself. Only an admin or a server-side program with certain credentials can add a user to the group.
My first tests using a topic were successful:
POST https://fcm.googleapis.com/v1/projects/<my_project_id>/messages:send
Authorization: Bearer <oauth token from GoogleCredential.getAccessToken()>
Content-Type: application/json; UTF-8
{
"message": {
"notification": {
"title": "Sample title",
"body": "Sample body 15:33:31"
},
"android": {
"ttl": "172800s"
},
"topic": "MyTopic"
}
}
My problem is that topics aren't closed. Any user can subscribe on any topic and I can't limit it (one can only hide the option but on code-level you can still subscribe to every topic).
The only possible approach I see is to create an Audience
and specify explicitly users by their user-id to belong to the audience.
I did this and I have now an Audience but there seems to be no way to specify an audience as message receiver. I tried to use the condition
field of the message
object (instead of the topic
field), however it seems that one can only specify topics in it.
Is there a way to send a message to an Audience group? Or is there an alternative way to achieve sending a message to a closed user group?