Detecting whether $state and $stateParams will kick in when receiving a push


I am working with the Ionic IO Push, and have realized via that passing $state in the payload does not result in anything if the app is active. The auto-go is only set when the app is not the main app (including closed). onNotification itself runs in all cases and will need to be what I need to handle the push for a running app. But how can one from within onNotification know that a passed $state is going to be used?

One alternative i guess is never to use $state and use my own custom fields and flags throughout. I imagine there is a more universal way. It would be nice if there were simply a second onNotificationActive or something that is an obvious different between active app pushes versus not.


check this blog

it helps me a lot


Thanks for this. I do not think it covers my exact problem as in their example notification["$state"] was used as a conditional and for me it is there in the active and in-active cases. What it did spark me noticing though was the notification[“foreground”] flag. The plugin itself is putting that there, and in my case I only need to check for foreground==true/1 and manually prompt and take them to the desired state. Once I get it working I will paste the snippet.


please share the answer when you find it, regards