You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am actually cp code from firebase_messaging/example/lib/main and it is possible that notification received from firabase is duplicated when app is in background mode, specially with part of a code: @pragma('vm:entry-point') Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async { await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); await setupFlutterNotifications(); showFlutterNotification(message); // If you're going to use other Firebase services in the background, such as Firestore, // make sure you call initializeApp before using other Firebase services. print('Handling a background message ${message.messageId}'); }
because if we just put code like: Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async { await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); } we will receive notification by default but not as heads up notification, so if we add showFlutterNotification(message); method, notifications will be duplicated. It is possible to avoid duplication or i misunderstood something? Thanks for answering.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am actually cp code from firebase_messaging/example/lib/main and it is possible that notification received from firabase is duplicated when app is in background mode, specially with part of a code:
@pragma('vm:entry-point') Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async { await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); await setupFlutterNotifications(); showFlutterNotification(message); // If you're going to use other Firebase services in the background, such as Firestore, // make sure you call
initializeAppbefore using other Firebase services. print('Handling a background message ${message.messageId}'); }
because if we just put code like:
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async { await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); }
we will receive notification by default but not as heads up notification, so if we add showFlutterNotification(message); method, notifications will be duplicated. It is possible to avoid duplication or i misunderstood something? Thanks for answering.Beta Was this translation helpful? Give feedback.
All reactions