Flutter Firebase notification is not displayed in onMessageOpenedApp and onBackgroundMessage

Viewed 259

I have an application Flutter and I use firebase messaging. On most smartphones the message is received normally in all states (onMessage, onMessageOpenedApp, onBackgroundMessage). But on some smartphones, notification doesn't come (onMessageOpenedApp, onBackgroundMessage), I've tried some tips and it didn't work for me. My last attempt was this, top-level function :

Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  await Firebase.initializeApp();
  print(
      "Background message: ${message.notification.title}, ${message.notification.body}");
}

void main() {
  FirebaseMessaging.onMessageOpenedApp.listen(_firebaseMessagingBackgroundHandler);
  FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
  runApp(InitApp());
}

I'm using:

  firebase_core : ^1.6.0
  firebase_messaging : ^10.0.6

Please I need tips on what else I can try to do.

0 Answers
Related