Reputation: 14213
I am trying to implement targeted GCM (Google Cloud Messaging) push notifications from our server to Android client app .
Previously we were using Parse.com for push notifications. We were using Parse channels field to target a user (each had it's Parse channel named by it's username). Client app was responsible to register on login to Parse to specific channel.
I'm trying to figure out is there GCM equivalent of those Parse channels.
Could topics be used for this? Or device groups?
How can I dynamically create/register to this "channel equivalent" from Android app?
Upvotes: 0
Views: 258
Reputation: 7741
I think topics can do it. GCM topic messaging allows your app server to send a message to multiple devices that have opted in to a particular topic. Based on the publish/subscribe model, topic messaging supports unlimited subscriptions per app. The app server sends messages with payloads up to 2KB to the topic, and GCM handles the message routing and delivers the message reliably to the right devices.
To subscribe to a topic, the client app calls GCM PubSub subscribe() with the GCM registration token and topic name.
private void subscribeTopics(String token) throws IOException {
GcmPubSub pubSub = GcmPubSub.getInstance(this);
for (String topic : TOPICS) {
pubSub.subscribe(token, "/topics/" + topic, null);
}
}
Upvotes: 1