I'm trying to add push notification using Google Cloud Messaging to my Android application. I don't need anything fancy, I just want to notify all users of the app when certain events happen.
I don't need to notify individual users, I always want to send the notification to every user. This is an internal app with a very limited number of users, it is not distributed publicly.
Now, as far as I understand the documentation I need a registration id for every notification I want to send. I don't really want to keep track of those as I don't need to identify individual devices.
Can I just broadcast to all devices without using any registration ids?
No, sorry, not at the present time.
If not, how can I get the registration ids of all registered devices? Do I have to keep track of those manually (outside the GCM communication)?
Yes, you have to keep track of those manually (e.g., have the app send you the registration ID via a Web service).
You can subscribe topic and send notification from server
Client :
private void subscribeTopics(String token) throws IOException {
GcmPubSub pubSub = GcmPubSub.getInstance(this);
pubSub.subscribe(token, "/topics/global", null);
}
Server :
{"to": "/topics/global","notification":{"message":"testmessage"}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With