diff --git a/lib/utils/notifications.dart b/lib/utils/notifications.dart index f6bac97..218d129 100644 --- a/lib/utils/notifications.dart +++ b/lib/utils/notifications.dart @@ -4,10 +4,6 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import '../main.dart'; -Future firebaseMessagingBackgroundHandler(RemoteMessage message) async { - print('received background notification'); -} - class Notifications { static Future initializeNotifications() async { FirebaseMessaging messaging = FirebaseMessaging.instance; @@ -18,13 +14,13 @@ class Notifications { } static Future listenForNotification(BuildContext context) async { - FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); - + // Received a notification while app is in foreground FirebaseMessaging.onMessage.listen((RemoteMessage message) async { navigateToScreen(context, message); showNotification(message); }); + // Opened a notification while app is in background FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async { navigateToScreen(context, message); });