Hey everybody,
I am implementing a push notification with “phonegap-plugin-push”. But i want to fire different action depending on app being on background of foreground. Can anyone help me to figure out how to achieve that?
Thank you very much.
Hey everybody,
I am implementing a push notification with “phonegap-plugin-push”. But i want to fire different action depending on app being on background of foreground. Can anyone help me to figure out how to achieve that?
Thank you very much.
NotificationEventAdditionalData.foreground returns a boolean which is true if the app is in foreground and false otherwise
Check out the docs for more nfo
Thank you very much for your answer @zeroEight, i am using “NotificationEventAdditionalData.foreground”, the problem is that when the app is in background and i tap, it open the app, but “this.pushObject.on(‘notification’)” is not being fired. So do you know i could achieve that to use NotificationEventAdditionalData.foreground ?
I eventually find out what was wrong with my code. I was sending payload wrong format, @zeroEight thank you for your help.
Hi @quieterkali,
would you share your code? I have the same issue. Or… actually I’m already using the NotificationEventAdditionalData.foreground but the problem is my code is run only when the app is already in foreground.
When the app is in background I need to show an alert after the user tapped the notification. Any idea?
Hello @greentreelabs,
The phonegap plugin push documentation explains quite well in which cases background notifications would run or not (directly or on tap notification). It is all about the way you organize your payload.
I read the docs and even thought they’re quite well written I wasn’t able to make it work. Instead, a simple answer here: https://stackoverflow.com/questions/37711082/how-to-handle-notification-when-app-in-background-in-firebase was the only solution I could find that worked.