Member-only story
Custom animated in-app notifications that are super easy to code
How to handle FCM notifications in Flutter AFTER they arrive?
Firebase Cloud Messaging for Flutter example
6 min readNov 23, 2020
In this tutorial, I will suggest the way of handling notifications after they have successfully arrived to our app. There are lots of tutorials that explain how to setup Android/iOS native part in order to receive them, which we will skip.
At the beginning, we will create a class called NotificationsManager that well be listening to notifications that are fetched via FirebaseMessaging instance:
factory NotificationsManager() {
if (_singleton == null) {
_singleton = NotificationsManager._();
}
return _singleton;
}
NotificationsManager._() {
_firebaseMessaging = FirebaseMessaging();
_onNotificationAction = StreamController.broadcast();
_startListeningNotifications();
if (Platform.isIOS) {
_setupIosPermissions();
}
_fetchCurrentTokenAndListenForNew();
}
static NotificationsManager _singleton…