Is there any way to tell when I've entered the app through a push notification?

I notice that I can tell when I’ve opened the app through a push notification using launchArgs

 if launchArgs and launchArgs.notification then

but I can’t tell if I’ve resumed the app from a notification.  There’s no distinction.  Any clean way of accomplishing this?

Hi @tameem50,

Are you following this code model? And, are you doing this from within “main.lua”?

[lua]

local launchArgs = …

if ( launchArgs and launchArgs.notification ) then

    print( “OK” )

end

[/lua]

Brent

Yes but that only tells me if I’ve launched the app from a push notification.  not resumed the app.  the hard part is telling if i’ve resumed the app from a push notification.

On iOS i check that I’ve received a notification in an inactive state like this:

 if systemState == "applicationSuspend" or systemState == "inactive" then lastEventData = event.custom end

But on android the systemState will be applicationResume which makes it impossible to tell if I resumed the app through a push notification or by manually going to it.  

I think on android the “system” event listener is called before the “notification” event listener but on iOS its the other way around.  cant find a way to accurately tell if I was an inactive state when I got my notification

Hi @tameem50,

If you’ve determined the “order” of system vs. notification checks is swapped between iOS and Android, could you do some kind of platform-conditional block which checks the first in sequence, then on confirmation of that, it calls a function to check the next in sequence? Then, only when both are satisfied, you take the action that you want for the user resuming from a push notification?

Brent

Hi @tameem50,

Are you following this code model? And, are you doing this from within “main.lua”?

[lua]

local launchArgs = …

if ( launchArgs and launchArgs.notification ) then

    print( “OK” )

end

[/lua]

Brent

Yes but that only tells me if I’ve launched the app from a push notification.  not resumed the app.  the hard part is telling if i’ve resumed the app from a push notification.

On iOS i check that I’ve received a notification in an inactive state like this:

 if systemState == "applicationSuspend" or systemState == "inactive" then lastEventData = event.custom end

But on android the systemState will be applicationResume which makes it impossible to tell if I resumed the app through a push notification or by manually going to it.  

I think on android the “system” event listener is called before the “notification” event listener but on iOS its the other way around.  cant find a way to accurately tell if I was an inactive state when I got my notification

Hi @tameem50,

If you’ve determined the “order” of system vs. notification checks is swapped between iOS and Android, could you do some kind of platform-conditional block which checks the first in sequence, then on confirmation of that, it calls a function to check the next in sequence? Then, only when both are satisfied, you take the action that you want for the user resuming from a push notification?

Brent