-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Bug Report
User-Reported Behavior
- On iOS: tapping an Omi notification opens the app but navigates to the last chat instead of the specific conversation
- On macOS beta: tapping a notification only shows the most recent notification, not the full notification history
Root Cause
The Flutter app is missing two critical FCM notification tap handlers:
1. FirebaseMessaging.onMessageOpenedApp — not registered (Background state)
When the app is in the background and a user taps an FCM push notification, Firebase fires FirebaseMessaging.onMessageOpenedApp. The message's data payload includes navigate_to (e.g. /chat/omi), but there is no listener registered for this event anywhere in the codebase.
File: app/lib/services/notifications/notification_service_fcm.dart
Method: listenForMessages() — only handles FirebaseMessaging.onMessage (foreground), not onMessageOpenedApp (background tap)
2. FirebaseMessaging.instance.getInitialMessage() — not called (Terminated state)
When the app is terminated and a user taps a notification to open it, getInitialMessage() should be called at startup to retrieve the triggering message and navigate accordingly. This is also absent.
3. iOS foreground notifications not shown for plugin type
In _shouldShowForegroundNotificationOnFCMMessageReceived(), only Android shows foreground notifications (return Platform.isAndroid). On iOS, plugin/chat notifications received while the app is in the foreground are silently dropped into a stream without triggering a visible notification or navigation.
Data Flow (for context)
Backend sends FCM via send_notification() with a full data payload:
# backend/utils/chat.py
ai_message = NotificationMessage(
notification_type='plugin',
navigate_to=f'/chat/{app_id}', # or '/chat/omi' for main
...
)
send_notification(user_id, app_name + ' says', message, NotificationMessage.get_message_as_dict(ai_message))The navigate_to field is present in the FCM payload — the app just never reads it on notification tap from background/terminated state.
Fix Required
In notification_service_fcm.dart, add to listenForMessages():
// Background: app in background, user taps notification
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
final navigateTo = message.data['navigate_to'];
if (navigateTo != null && navigateTo.isNotEmpty) {
NotificationUtil.handleDeepLink({'navigate_to': navigateTo});
}
});
// Terminated: app was closed, user taps notification to open
FirebaseMessaging.instance.getInitialMessage().then((RemoteMessage? message) {
if (message != null) {
final navigateTo = message.data['navigate_to'];
if (navigateTo != null && navigateTo.isNotEmpty) {
NotificationUtil.handleDeepLink({'navigate_to': navigateTo});
}
}
});Also expose _handleAppLinkOrDeepLink as a public static method on NotificationUtil.
Affected Platforms
- iOS (primary)
- macOS beta
- Potentially Android (though foreground notification display works there)
Affected Notification Types
- Omi AI response notifications (
notification_type: 'plugin') - App plugin chat notifications
References
app/lib/services/notifications/notification_service_fcm.dart—listenForMessages()app/lib/services/notifications.dart—_handleAppLinkOrDeepLink()backend/utils/chat.py—send_chat_message_notification()backend/utils/app_integrations.py—send_app_notification()