I know the flutter_local_notifications_plugin allows an app to display notifications.
I want to access the data of notifications that is received, regardless of whether the app is running in the foreground, in the background, or not running.
Essentially the app needs to
- Add that notification to a persistent storage, and
- Depending on the notification, make a call to an API (eg an HTTP GET), and
- Depending on user preference settings, display a local notification
Note the question is not about the detail of implementing these three things as those would each be worthy of a whole article. But how to "receive" these events in each of the three possible app states, on both Android and iOS?
Broadly I expect some kind of broadcast receiver would need to be registered and a call-back needs to be created for when the event is triggered. I imagine this callbackmay want to be in a special Isolate perhaps since it can't depend on the app being in any particular state.