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

How to redirect users with node-gcm and phonegap-plugin-push ? #214

Closed ronycohen closed 8 years ago

ronycohen commented 8 years ago

Hello, currently I'm using node-gcm (amazing thank you!) and I'm properly getting notifications with phonegap-plugin-push.

When the app is closed, a click on the notification open the Ionic / cordova app wthout problems.

I would like to do more and redirect the user to a defined Route $state inside the application.

Do you know how to do that ?

Regards,

hypesystem commented 8 years ago

Hey @ronyrun, I am afraid this is more of an Ionic/cordova-related question. I would recommend you ask it on StackOverflow :smile:

I/we don't have much experience with cordova og ionic, I'm afraid :frowning:

ronycohen commented 8 years ago

Hello @hypesystem thank you for your answer !

Can you confirm to me that the contentAvailable: true, will create a "content-available": "1" in the datas sent ? Currently that's probably my issue because when the app is closed or in background, I get the notification but when the user click on the notification my event handler is not working.

var messageTest = new gcm.Message({
    priority: 'high',
    contentAvailable: true,
    delayWhileIdle: true,
    timeToLive: 3,
    data: {
        key1: 'message1',
        key2: 'message2'
    },
    notification: {
        title: "Hello, World",
        icon: "icon",
        body: "This  is a notification that will be displayed ASAP.",
    },
});
ronycohen commented 8 years ago

I solve the issue !

the notification property has to be deleted and everything needs to go into the data property.

hypesystem commented 8 years ago

Great! I'm glad you found a solution!

The notification field is for information that is shown on the device as soon as the notification is received. We have heard of similar issues with phonegap/cordova/ionic before: the notification field doesn't seem widely supported in those libraries.

ronycohen commented 8 years ago

you should add that to your readme :)

hypesystem commented 8 years ago

We actually have a section about it: https://github.com/ToothlessGear/node-gcm/#gcm-client-compatibility :smile:

ronycohen commented 8 years ago

I'm so sorry ! Thank you very much !