This repository has been archived by the owner on Jul 21, 2022. It is now read-only.
Using FCM to get notifications working on foreground, background and when app gets killed #7
praful0203
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While working with Firebase Cloud Messaging(FCM), we have found that the notifications were getting delivered to a targeted device, but not showing up in the device.
The reason behind that was, in Android, notifications are sent to Notification Channels which are used to control how notification is delivered. The default FCM channel used is hidden from users and provides a "default" importance level, whereas Heads up notifications require a "max" importance level.
In order to resolve this, we first created a new channel with a maximum importance level & then assigned incoming FCM notifications to this channel. For this, we used Awesome Notifications Plugin.
Initially, we used both callbacks provided by FirebasMessaging,
FirebaseMessaging.onMessage.listen((RemoteMessage message) {...}
FirebaseMessaging.onBackgroundMessage((message) => ...)
for handling notifications when the app is in foreground, background and killed. The issue which we encountered here was, when the app was running in the background or get killed, we were getting two duplicate notifications.
After digging in and searching lots of articles and GitHub issues, we have figured out that we just have used one callback named
FirebaseMessaging.onMessage.listen((RemoteMessage message) {...}
to handle all the scenarios.So, in future, if anyone works with the notifications, then ensure you are not subscribing to multiple listeners for the same notification.
Beta Was this translation helpful? Give feedback.
All reactions