omi icon indicating copy to clipboard operation
omi copied to clipboard

bug: Tapping Omi response notifications doesn't navigate to the correct conversation

Open mdmohsin7 opened this issue 9 months ago • 5 comments

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()

mdmohsin7 avatar Feb 25 '26 17:02 mdmohsin7

yes Android presents same behaviour

hugoaap-code avatar Feb 25 '26 18:02 hugoaap-code

@mdmohsin7 please close within this week mar 13

aaravgarg avatar Mar 11 '26 14:03 aaravgarg

@mdmohsin7 bro

aaravgarg avatar Apr 20 '26 11:04 aaravgarg

Opened a fix that resurrects closed unmerged #5127 with Gemini’s type-safe navigate_to parsing applied:

  • FirebaseMessaging.onMessageOpenedApp (background tap)
  • getInitialMessage() (terminated tap)
  • NotificationUtil.handleNavigateTo + unit-tested navigateToFromFcmData

PR: will link after create.

aryanorastar avatar Aug 05 '26 16:08 aryanorastar

Opened #11144 — resurrects closed unmerged #5127 with Gemini’s type-safe navigate_to parsing:

  • FirebaseMessaging.onMessageOpenedApp (background tap)
  • getInitialMessage() (terminated tap)
  • NotificationUtil.handleNavigateTo + unit-tested navigateToFromFcmData

aryanorastar avatar Aug 05 '26 16:08 aryanorastar