Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new topic, add subscribers to a topic #208

Open
chirag200666 opened this issue Feb 2, 2016 · 5 comments
Open

Create new topic, add subscribers to a topic #208

chirag200666 opened this issue Feb 2, 2016 · 5 comments

Comments

@chirag200666
Copy link
Contributor

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 :

  • Creation of a new topic
  • Subscribe a user to a topic using his token
  • get list of subscribed topics of a user.
@eladnava
Copy link
Collaborator

eladnava commented Feb 2, 2016

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

@chirag200666
Copy link
Contributor Author

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
Copy link
Contributor Author

After reading more I found :

  • There is no topic create API, a topic is automatically created when a user token is subscribed to a topic
  • There is an API call for adding one user token to one topic to create the subscription.
  • There is a second API method which takes a list of tokens, a topic and creates the subscription. The unsubscribe from topic API also works the same way.

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
Copy link
Collaborator

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 😄

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
Copy link
Contributor Author

I did an amateurish PR, want your inputs.
#211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants