Node-gcm with phonegap-plugin-push - How to $state redirect when app closed


#1

Hello,

I use node-gcm with phonegap-plugin-push.

When App is Closed :
I would like to redirect the user to a specific $state when the user click on the notification

Do you know how to do that ?

Thank you.


#2

What you’re talking about is called a cold start.

A cold start basically is when the user launches the app through your notification instead of the usual way. To add functionality to handle that you will need to detect a cold start inside of your push.on('notification', callback) callback function.

When you receive the data in that callback function, one of the parameters will be data.additionalData.coldstart. If that’s set to true that means the user has entered the app through a push notification.

From there, you can redirect the user to the appropriate page. If the page is dependent on the type of notification then you need to send additionalData with your push notifications to identify the type of notification being sent.


#3

Thank you very much :slightly_smiling:

I had issues with node-gcm and didn’t get event fired when the app was not in foreground.
It’s ok now :slightly_smiling:

thank you !


#4

I didn’t know node-gcm existed till you mentioned it.

Thank you!