Push Notification : Detect app state


Hey Guys,

I integrated Push Notification with the PushWoosh service successfully in my Ionic App.
Its working like a charm but there is one thing I dont get:

When the app is already up and running an in the front my Push-Handler-Method is called in the moment the push arrives. This leads to undesireable behaviour because the app calls another Page on base of the content of the push message. If the App is totally closed and gets opened when the user touches the Push Message my Push Handler isnt called at all. Only when the App is Running in the Background and is loaded to foreground when the user touches the PushMessage, everything works fine.

How can i detect if the App is already in the front to prevent the handler from executing?
Basically I need something like this for IOS and for Android.


}else if(AppWasInBackground){

}else if(AppWasNotRunningAtAll){


Thanks in advance for any help


For Android the following is working as far as i can see (using Pushwoosh). For iOS i dont get it yet:

var notification = event.notification;

    if(typeof(userData) != "undefined") {
        console.warn('user data: ' + JSON.stringify(userData));
    if (notification.foreground){		//app was already running
     	securealert("Foreground push");  
    else{   // otherwise we were launched because the user touched a notification in the notification tray.
        if (notification.coldstart){
            securealert("Coldstart push");
        	securealert("Active Background Push");