What I want to achieve
I'm implementing FCM in flutter for iOS in such a way that in every state (foreground, background and terminated) when the notification is received, we need to show an alert with sound on the screen for some time (Say 2 mnts).
What is clear
Implementation is clear when the app is in foreground which can easily be done using onMessage
callback.
Where is the issue
The confusion is with background and terminated part:
- How to detect in the background that notification is received (I know on Resume is called when we click on the notification in the notification try). But we need to show alert on notification arrival not on Clicking the notification.
- How to detect when the app is terminated(I know onLaunch is called when we click on the notification in the notification tray) But we need to show alert on notification arrival not on Clicking the notification.
- Is it possible to show any system alert when the app is not running like when notification is received while app is terminated and we show a customized alert like Alarm alert on the screen.
- There is onBackgroundMessage call back but I don't know if it works for iOS (as documentation is more focused on Android settings in onBackgroundMessage call back part).