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

Create new topic, add subscribers to a topic #208

Open chirag200666 opened 8 years ago

chirag200666 commented 8 years ago

This is a feature request. It will be very useful to have the functionalities in the node-gcm packages as many people would want to use them :

eladnava commented 8 years ago

Hi @chirag200666, Great call. We definitely want to implement these calls -- do you have any free time to help with this?

chirag200666 commented 8 years ago

Hi @eladnava , I am interested, I anyway have to implement for the project I am working on. I've been playing around with sails js, but not so comfortable with node, so some guidance would be appreciated.

chirag200666 commented 8 years ago

After reading more I found :

https://developers.google.com/instance-id/reference/server

My Approach : I have created a Subscription model (Subscription.js file) similar to that of Sender. Which has two functions, first one to create a subscription which takes a token or a list of tokens & a topic. The second function takes a list of tokens and a topic to be unsubscribed.

I had a question: Should I implement the retry strategy we have in the Sender.js to the Subscription.js or it is not required.

hypesystem commented 8 years ago

Nice! Could you make a PR with your suggested addition, so we can continue the discussion there? That will allow us to talk about concrete code, which is often much easier than talking about concepts :smile:

I am not sure about the name, Subscription. If this functionality is only used for topics, maybe it should be called something more explicit, like TopicSubscriber?

The retry strategy we currently have in the Sender should actually be fixed to respect the Retry-After header we might get from GCM (see #94).

I think it would be a good idea for the topic subscription functionality to have retrying (and backoff) logic, too, but maybe we could extract that particular logic and reuse it in both the Sender and your new abstraction.

chirag200666 commented 8 years ago

I did an amateurish PR, want your inputs. https://github.com/ToothlessGear/node-gcm/pull/211