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

added support for subscribe to topic , un-subscribe to topic #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scripterkaran
Copy link

This provides added support to subscribe to GCM topics.

PS: Please create a development branch so we contributors can contribute without messing the master repo.

@akreienbring
Copy link

@promactkaran
Please have a look at my fork https://github.com/akreienbring/GCMPushPlugin

I also added Topic support (for Android). Would you mind using the same interface to make it easier to merge both?

/**
 * Subscribe to a topic
 * @param registrationId, The registration id that was optained during registration
 * @param topics, an array of topics that may not be empty
 * @throws an error if not all parameters are provided or the plugin fails during the subscription
 */
GcmPushPlugin.prototype.subscribeTopics = function (registrationId, topics) {
    if(!registrationId || !topics || topics[0] == null){
        throw new Error("GcmPushPluginError", "Please provide the registrationId and at least one topic.")
    }else{
        exec(this.successCB, this.errorCB, "GCMPushPlugin", "subscribeTopics", [{registrationId: registrationId, topics: topics}]);
    };
};

/**
 * Unsubscribe from a topic
 * @param registrationId, The registration id that was optained during registration
 * @param topics, an array of topics that may not be empty
 * @throws an error if not all parameters are provided or the plugin fails during the unsubscription
 */
GcmPushPlugin.prototype.unsubscribeTopics = function (registrationId, topics) {
    if(!registrationId || !topics || topics[0] == null){
        throw new Error("GcmPushPluginError", "Please provide the registrationId and at least one topic.")
    }else{
        exec(this.successCB, this.errorCB, "GCMPushPlugin", "unsubscribeTopics", [{registrationId: registrationId, topics: topics}]);
    };
};

@scripterkaran
Copy link
Author

The thing is, I am not sending registration Id in my topic subscription. The registration Id is stored in a dictionary by OS itself.

When I register to topic, it automatically takes the device registration ID and registers the device to specific topic. I wouldn't have to deal with storing the ID , in javascript Side.

What do you suggest ?

@akreienbring
Copy link

Ok... maybe it makes sense to have the same behaviour on Android. I could store the token in the Plugin once the registration took place.

@akreienbring
Copy link

I just removed the need to pass the registrationId when subcribing / unsubscribing to topics.

The token is now hold in the plugin once you registered with gcm.

@akreienbring
Copy link

@scripterkaran It seems that Gonzalo has no interest in merging our improvements :-( What do you think of merging yours and mine? If you offer me a pull request I would be glad to accept it. But I would prefer the event based approach I introduced to the plugin. What do you think?

@gonzaloaune
Copy link
Owner

I'll be reviewing everything today guys, I had some personal things to take
care. Thanks for everything.

On Sunday, October 18, 2015, André Kreienbring [email protected]
wrote:

@scripterkaran https://github.com/scripterkaran It seems that Gonzalo
has no interest in merging our improvements :-( What do you think of yours
and mine? If you offer me a pull request I would be glad to merge it. But I
would prefer the event bases approach I introduced to the plugin. What do
you think?


Reply to this email directly or view it on GitHub
#8 (comment)
.

G.-

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

Successfully merging this pull request may close these issues.

3 participants