Phonegap Firebase Push Notification not firing event listener when app opens, or when app is in background
Your notification send logic is solid, but your concerns are also valid. If you want to read more on the subject, google notification vs data notifications
, there are some good articles explaining it.
Push notifications have a special native on open receiver, your WebView must register for those events. However, if you look at the source, notification open events are not handled. There's nothing you can do short of forking the repository.
Furthermore, .on('notification')
events are not received by your WebView when the app is killed because.. well, your app is killed. Your app does not receive the notification when it is killed, Android OS receives it and decides what to do with it.
As to why you noticed the issue on Android 8, recent versions of Androids have more aggressively been killing apps in the background, to save battery: Doze and Adaptive battery. Newer android apps are simply being killed off sooner.
If at all possible, I advise you to switch to cordova-plugin-firebase
, a more actively-maintained plugin. Alternatively, learn a bit of android and write your own plugin.