capacitor-community / fcm

Enable Firebase Cloud Messaging for Capacitor apps
https://capacitor.ionicframework.com/docs/
MIT License
237 stars 83 forks source link

Notification receive different behavior #64

Closed hembachrterran closed 2 years ago

hembachrterran commented 3 years ago

Hi,

I switched my application FCM to this package from an old one. The case:

I would like to explain some behavior difference between this FCM package and the old Cordova FCM package (cordova-plugin-fcm-with-dependecy-updated): Some lines from Cordova package readme:

Application is in foreground:

The notification data is received in the JavaScript callback without notification bar message (this is the normal behavior of mobile push notifications). For Android, to show the notification received on the foreground, it's recommended to use cordova-plugin-local-notification as it provides many presentation and interaction features. Application is in background or closed:

The device displays the notification message in the device notification bar. If the user taps the notification, the application comes to foreground and the notification data is received in the JavaScript callback. If the user does not tap the notification but opens the application, nothing happens until the notification is tapped.

The important parts in the foreground behavior, when the app get a new notification while it is in foreground: it does nothing. In the Capacitor-C FCM package, the subscription run the code in foreground too, immediately without click on the push notification. The difference in the background case also similar "If the user does not tap the notification but opens the application, nothing happens until the notification is tapped.", so if the user get notification, but doesn't tap on it, in my case the app should not be redirect to a different page.

Feature request: It would be nice if the payload get a new parameter like the "coldstart" and "foreground" parameters, for example "tapped", this will be a boolean, and it will be true, if the notification is tapped and will be false when the subscription handler called automatically by FCM.

stewones commented 2 years ago

have you tried the official push notifications plugin + custom presentationOptions?

this plugin is intended to only enable FCM