How exactly can I “create a ‘High Priority’ notification channel on Android” as mentioned in the Firebase documentation?
The following is mentioned in the Firebase documentation here: https://firebase.google.com/docs/cloud-messaging/flutter/receive
Foreground and Notification messages
Notification messages which arrive while the application is in the foreground will not display a visible notification by default, on both Android and iOS. It is, however, possible to override this behavior:
- On Android, you must create a “High Priority” notification channel.
- On iOS, you can update the presentation options for the application.
For iOS, I managed to display messages while the app is in the foreground by writing the following code (after researching, since setForegroundNotificationPresentationOptions
isn’t mentioned in the above documentation):
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: false,
sound: true,
);
However, this setForegroundNotificationPresentationOptions
did not work for Android. How exactly should I “create a ‘High Priority’ notification channel” as the documentation suggests?
I’ve tried setting the priority in the “Compose Notification”(Firebase Console) settings to High
or IMPORTANCE_HIGH
, but it didn’t have any effect (notifications appear when the app is in the background, but not in the foreground).
Many resources online suggest using the flutter_local_notifications
package for Android. While I am open to using it if necessary, the official Firebase documentation does not mention flutter_local_notifications
at all.
If flutter_local_notifications
is indeed required, I will use it, but it seems inconsistent with the documentation’s statement that “it is possible to override this behavior” and “On Android, you must create a ‘High Priority’ notification channel.”
Is there a way to override this behavior on Android simply by creating a “High Priority” notification channel as described in the documentation?
References:
- How to specify Android notification channel for FCM push messages in Android 8
- https://developer.android.com/develop/ui/views/notifications/channels
- https://zenn.dev/rafekun/articles/ef8a22f9fe90bd (Japanese)