What is the correct way to handle a user clicking a push notification to open the app?

I want a method to be triggered by this action and read a custom field from the push JSON. A custom ID to take the user to the story they were interested in. What’s the correct way now and are there gotchas like platform differences between Android and IOS?

Push notifications have a pretty well defined set of behaviors on how the app interacts:

If you tap on the app icon to start it, or bring it back to the foreground, all push notifications will be lost. If the user chooses to interact with the push notification then you will get one of two behaviors.  If the app is not running (not backgrounded, cold start), the notification will be made available to your app via launchArgs. If your app is backgrounded, it will be brought to the foreground and you will get a notification event.  

There is a third behavior, if the app is actively in the foreground when the notification arrives, you will get a notification event without the user having to interact with the push notification.

Both the launchArgs and the notification event contain the same table of information. One of the items in that table is a sub-table of custom data (event.custom). It’s up to your push sending platform to populate this table. I believe it must be named “custom”.  See:

https://docs.coronalabs.com/guide/events/appNotification/index.html

This doc is really for local notifications, but there is an example of the custom table included:

https://docs.coronalabs.com/plugin/notifications/scheduleNotification.html

Rob

Push notifications have a pretty well defined set of behaviors on how the app interacts:

If you tap on the app icon to start it, or bring it back to the foreground, all push notifications will be lost. If the user chooses to interact with the push notification then you will get one of two behaviors.  If the app is not running (not backgrounded, cold start), the notification will be made available to your app via launchArgs. If your app is backgrounded, it will be brought to the foreground and you will get a notification event.  

There is a third behavior, if the app is actively in the foreground when the notification arrives, you will get a notification event without the user having to interact with the push notification.

Both the launchArgs and the notification event contain the same table of information. One of the items in that table is a sub-table of custom data (event.custom). It’s up to your push sending platform to populate this table. I believe it must be named “custom”.  See:

https://docs.coronalabs.com/guide/events/appNotification/index.html

This doc is really for local notifications, but there is an example of the custom table included:

https://docs.coronalabs.com/plugin/notifications/scheduleNotification.html

Rob