Home > Back-end >  FCM Notification not showing in System tray on android device
FCM Notification not showing in System tray on android device

Time:11-04

I have implemented Firebase Cloud Messaging in my flutter application. I am trying to notification from Firebase Console to android application. I am getting notification data in application but I am not able to see notification in system tray.

Following id pubspec file

# For Firebase Cloud Messaging


firebase_core: ^2.1.1
  firebase_messaging: ^14.0.3

Getting firebase token

FirebaseMessaging messaging = FirebaseMessaging.instance;
messaging.getToken().then((value){
  print('Firebase messaging get token $value');
});

On notification received

FirebaseMessaging.onMessage.listen((RemoteMessage event) {
      print("Firebase messaging recieved");
      print(event.notification!.body);
    });

Added intent filter in manifest

<intent-filter>
         <action android:name="FLUTTER_NOTIFICATION_CLICK" />
           <category android:name="android.intent.category.DEFAULT" />            </intent-filter>

Did I miss something to receive notification in system tray.

CodePudding user response:

You have to check all this point below:

Android SDK version

Android 13 introduces a new runtime permission for showing notifications. This affects all apps running on Android 13 or higher that use FCM notifications.

Your app will also need to request the runtime version of this permission via the constant, android.permission.POST_NOTIFICATIONS. Your app will not be allowed to show notifications until the user has granted this permission.

Types Of Messages

The notification message, is handled by the FCM SDK. It goes directly to the Android Notification’s tray, if the application is in background/killed state, while if the application is in foreground then it will get delivered to the onMessage callback in the firebase_messaging plugin.

The data message, is handled by the client application. The data message will call onMessage or onBackgroundMessage callback if the application is in foreground, background, or killed. If you use only data message in the request, you can then use flutter_local_notification to display the notification.

  • Related