I am confused as to which packages should I implement in my Angular 14 Ionic 6 Capacitor 4 app, for sending and receiving notifications between app users. I need to be able to handle incoming messages:
- When app is in background - display a tappable notification (pushing to the notifications tray is not enough!) that will bring the app to foreground and further route based on received data payload.
- When app is in foreground - process logic based on data payload received.
My initial approach was to implement with @capacitor/push-notifications, with the two listeners implemented:
pushNotificationReceived
pushNotificationActionPerformed
However, I found the following shortcomings with that approach:
- In background - messages are only delivered to the notifications tray - not popping up.
- In background, un-tapped notifications will never be processed by the app leading to important data that must mutate the application state - to be lost!
- In foreground, the much needed baloon popup notifications in background - are now shown (when not really needed to be shown).
Then I encountered the [firebase/messaging service worker][1] approach.
I have not yet implemented it at all, but it seems to me, that while offers the onBackgroundMessage method to capture and handle background notifications, to fall short on:
- Not leveraging the native notification service offered by Android/iOS
- Not showing any popup notification, unless I implement it myself(?)
At this point I'm somewhat confused:
- Is it possible that my requirements can only be met by using BOTH approaches and packages?
- Is it at all possible to implement both? (in which case, the same token I register upon the 'registration' listener registration in initPush(), will serve BOTH?)
- If one approach is enough - which is it, and how to overcome what seems to me missing, in order to fulfill my requirements?
Thank you! [1]: https://firebase.google.com/docs/cloud-messaging/js/receive