ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.3k stars 206 forks source link

Topic subscription in Gcm #183

Closed sunojvijayan closed 8 years ago

sunojvijayan commented 8 years ago

Will it be possible to subscribe to topics and send topic based push using this plugin. I was wondering that in that case we could avoid sending registration ids along with push and send push on a topic and let Gcm do all the id handling. Is this possible?

eladnava commented 8 years ago

@sunojvijayan You can send push notifications to devices that subscribed to a topic with node-gcm.

However, subscribing to topics needs to happen on the device, not on the server.

The following code sends a message to all devices that subscribed to a topic:

// Send to a topic, with no retry this time
sender.sendNoRetry(message, { topic: '/topics/global' }, function (err, response) {
    if(err) console.error(err);
    else    console.log(response);
});
sunojvijayan commented 8 years ago

Thanks eladnava. Thanks a lot for your help. I am using phonegap-plugin-push on the client side. Not sure if it supports registering to topics. Can anyone suggest any good plugin for the client side that supports multiple topic registration. Thanks in advance.

eladnava commented 8 years ago

@sunojvijayan It isn't supported yet, according to this issue: https://github.com/phonegap/phonegap-plugin-push/issues/79

Hello, It seems that subscribing to topics is not implemented.

You may be able to find another client library for phonegap, however, I am not aware of one.

hypesystem commented 8 years ago

I think this issue is resolved :)