Google Cloud Messaging sends notification to all devices

I am new to GCM. I would like to send a message to all devices on which the application is installed. I read about registration_id: after the first connection to GCM, Google sends this unique string to the device. I am new to the server world, but if I'm not mistaken, on the server side, to send notifications to devices, I need to send an registration_id array and a message to Google.

Does Google know how it has a registration id? Is there a way to send messages to all devices without going through a registration ID? Thanks.

+8
android notifications google-cloud-messaging
source share
6 answers

Is there a way to send messages to all devices without transmitting the registrar ID?

No way. After successfully registering with GCM, you (the Android application) must send the registration identifier to your application server and store them somewhere in the database, for example. This registration ID will be used to send a notification to a specific device.

To send a notification about all devices, this means that then we will select all registration identifiers from this database, and, as you said, put them into an array and pass them on to GCM.

+11
source share

With GCM 3.0, you can now send notifications for all devices thanks to the support of themes. The application must subscribe to one or more topics, and the server can send notifications to this issue without specifying individual devices.

https://developers.google.com/cloud-messaging/topic-messaging

You can record all devices in a topic called "global", and then send a message to "/ themes / global", and not send them to all registration_id.

+15
source share

You need to send a list of reg id devices, and this list should not exceed 1000, this is a limitation of GCM, if you want to send a message to more than 1000 devices, then you need to break the list into pieces of 1000.

+6
source share

YES, there is a way to send a message to everyone!

Just send the value "/ themes / global" to the 'to' field, and not to the registration_ids field identifiers.

For example, in php:

'to' => "/topics/global", 

not this:

 'registration_ids' => $this->devices 
+6
source share

Create a notification_key that identifies the device group by mapping a specific group to all groups associated with registration tokens (you can create notification keys on the application server). With notification_key instead of sending one message to one registration token at a time, the application server can send one message to notification_key , and GCM will then send a message to all group registration markets.

Also note that the maximum number of members allowed for the notification_key button is 20 .

The Google Dev website has added new guidance for this topic in particular. https://developers.google.com/cloud-messaging/notifications#sending_downstream_messages_to_device_group

+1
source share

I think there is confusion here. I used the github sample code (a Java application server deployed to Tomcat, for example) and an Android application. There I did not “skip” or “send” any registration identifier to the application server. He called the appropriate APIs to get registration identifiers and use them to send notifications. Why does each thread about the GCM registration identifier say that it is necessary to transfer registration identifiers to a third-party application server? I'm afraid I do not agree. I think that a third-party application server can request the GCM server itself to find out which devices have registered to receive a notification from a specific sender (sender ID). To manually transfer registration identifiers to a third-party application server, the whole purpose of process automation. Maybe I missed something, or I'm using outdated content. In any case, how can an automated process include manual intervention after it starts?

-one
source share

All Articles