Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

What is the correct way to handle a user clicking a push notification to open the app?
Started by henrik5 May 23 2018 06:31 AM

1 reply to this topic
push notifications
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Contributor

  • 249 posts
  • Corona SDK

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?

[TOPIC: post.html]

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,529 posts
  • Enterprise

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:




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