Naveen Bellary
Naveen Bellary

Reputation: 1

OnNotificationGCM is not called in ionic

As in this post i tried all the ways, but still not getting registration id. Kindly some one help me on this.

I am able to see the registration id in eclipse's logcat but it is not calling onNotificationGCM method.

Upvotes: 0

Views: 53

Answers (1)

Mudasser Ajaz
Mudasser Ajaz

Reputation: 6257

First of all use latest push plugin. Install plugin to your project with this command:
ionic plugin add phonegap-plugin-push
To register your device use this line in your js code, this line will only register your device.

var push = PushNotification.init({ "android": {"senderID": "your-sender-id"}} );

Now that your device has been registered, and event with device token is generated from GCM service,which you can receive in your application using following code

push.on('registration', function(data) {
        // data.registrationId , use this token
});

That is it. You do not have to use old plugin because latest one is more simpler to use. Here is link to documentation of latest plugin.

Upvotes: 1

Related Questions