From 933161cb653e58e5f9e450cbf0567719efcbfd92 Mon Sep 17 00:00:00 2001 From: Patrick Britton Date: Wed, 4 Feb 2026 18:01:01 -0600 Subject: [PATCH] Fix Android notification click bug and improve FCM logging - Add FLUTTER_NOTIFICATION_CLICK intent filter to AndroidManifest.xml - Extend initial notification message delay for terminated-state deep linking - Add robust logging to notification listeners for easier debugging --- sojorn_app/android/app/src/main/AndroidManifest.xml | 5 +++++ sojorn_app/lib/services/notification_service.dart | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sojorn_app/android/app/src/main/AndroidManifest.xml b/sojorn_app/android/app/src/main/AndroidManifest.xml index ae38f06..9f4cb26 100644 --- a/sojorn_app/android/app/src/main/AndroidManifest.xml +++ b/sojorn_app/android/app/src/main/AndroidManifest.xml @@ -52,6 +52,11 @@ + + + + + diff --git a/sojorn_app/lib/services/notification_service.dart b/sojorn_app/lib/services/notification_service.dart index 2b146d3..7e9a4bd 100644 --- a/sojorn_app/lib/services/notification_service.dart +++ b/sojorn_app/lib/services/notification_service.dart @@ -229,7 +229,10 @@ class NotificationService { }); // Handle messages when app is opened from notification - FirebaseMessaging.onMessageOpenedApp.listen(_handleMessageOpen); + FirebaseMessaging.onMessageOpenedApp.listen((msg) { + debugPrint('[FCM] onMessageOpenedApp triggered: ${msg.notification?.title}'); + _handleMessageOpen(msg); + }); // Handle foreground messages - show in-app banner FirebaseMessaging.onMessage.listen((message) { @@ -241,9 +244,9 @@ class NotificationService { // Check for initial message (app opened from terminated state) final initialMessage = await _messaging.getInitialMessage(); if (initialMessage != null) { - debugPrint('[FCM] App opened from notification'); - // Delay to allow navigation setup - Future.delayed(const Duration(milliseconds: 500), () { + debugPrint('[FCM] App opened from TERMINATED state via notification: ${initialMessage.notification?.title}'); + // Delay to allow navigation setup (extended to 1000ms for safety) + Future.delayed(const Duration(milliseconds: 1000), () { _handleMessageOpen(initialMessage); }); }