Skip to content

Fix Android deep links broken across all notification types - #4803

Merged
beastoin merged 1 commit into
mainfrom
fix/deep-link-routing-4799
Feb 14, 2026
Merged

beastoin merged 1 commit into
mainfrom
fix/deep-link-routing-4799

Conversation

@beastoin

Copy link
Copy Markdown
Collaborator

Summary

Root Cause Analysis

All 4 bugs contributed to #4799 ("Android deep links broken across all notification types"):

Bug Impact Files
Race condition ALL URL-based deep links fail on cold start app_shell.dart
No bounds check /apps crashes on malformed URL app_shell.dart
Missing routes Task reminders + fact notifications go nowhere home/page.dart
Empty string fallback Notifications without navigate_to route to home instead of being ignored notification_service_fcm.dart

Test plan

  • Cold start: tap notification when app is killed → should navigate to correct page
  • Warm start: tap notification when app is in background → should navigate to correct page
  • /apps deep link with malformed URL → should not crash
  • Task reminder notification → should navigate to Action Items tab
  • Notification without navigate_to → should not navigate away from current page

Fixes #4799
Fixes #4763
Fixes #4762

🤖 Generated with Claude Code

4 bugs causing deep links to silently fail:

1. Race condition: initDeepLinks() fired before providers initialized on
   cold start, so getInitialLink() raced against cache loading (#4763)
   Fix: await _initializeProviders() before calling initDeepLinks()

2. Missing bounds check: /apps deep link crashed on malformed URL when
   pathSegments had only 1 element (#4762)
   Fix: add pathSegments.length > 1 guard

3. Missing route: /action-items and /facts not handled in home page
   navigation switch, so task reminder notifications went nowhere
   Fix: add action-items (tab 1) and facts (tab 2) cases

4. Empty string fallback: FCM navigate_to defaulted to "" instead of
   omitting the key, bypassing the null check in the tap handler
   Fix: only add navigate_to to payload when present and non-empty

Fixes #4799, fixes #4763, fixes #4762

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses several critical bugs related to deep linking and notifications in the Android app. The changes include fixing a race condition during app initialization, preventing a crash from malformed URLs by adding a bounds check, adding missing navigation routes for notifications, and improving the handling of notification payloads. All fixes are well-implemented and robust. The code quality is good, and I have no further suggestions for improvement.

@beastoin

Copy link
Copy Markdown
Collaborator Author

E2E Test Results (Android Emulator)

Environment: emulator-5554 (API 35, x86_64), dev flavor debug build

All 8 tests PASS:

Test Route Start Type Result
Malformed /apps (no ID) https://h.omi.me/apps Warm PASS — no crash
Valid /apps (fake ID) https://h.omi.me/apps/fake-id Warm PASS — graceful handling
/unlimited navigation https://h.omi.me/unlimited Warm PASS — navigated to UsagePage
Cold start malformed /apps https://h.omi.me/apps Cold PASS — app starts, no crash
Cold start valid /apps https://h.omi.me/apps/id Cold PASS — app starts cleanly
Cold start /tasks https://h.omi.me/tasks/token Cold PASS — "not found" snackbar
omi:// scheme malformed omi://apps Warm PASS — no crash
omi:// scheme cold start omi://apps/id Cold PASS — app starts

Screenshots

Cold start /tasks deep link — shows error snackbar correctly:

Cold start tasks

/unlimited deep link — navigated to UsagePage:

Unlimited navigation

Notes

  • Fix 3 (action-items route) and Fix 4 (empty string fallback) can't be tested via ADB deep links — they go through the notification tap handler, not the URL deep link handler. Verified via code review.
  • https:// deep links require -c android.intent.category.BROWSABLE + explicit component on emulator (no assetlinks.json)

@beastoin

Copy link
Copy Markdown
Collaborator Author

E2E Test Results: Fix 3 & Fix 4 (Notification Tap Handler)

Tested by injecting payloads directly into NotificationUtil.onActionReceivedMethodImpl() via temporary test buttons — same code path as real notification taps.

Fix 3: action-items route — PASS

Simulated notification tap with payload: {navigate_to: "/action-items"}.
App navigated from Conversations (tab 0) to Action Items (tab 1).

Fix 3: action-items navigation

Fix 4: Empty string navigate_to — PASS (demonstrates the bug Fix 4 prevents)

Test Payload Result
4a: no key {some_other_key: "value"} Stayed on current page — handler returned early at null check
4b: empty string {navigate_to: ""} Navigated to home page — empty string bypassed null check, caused disruptive pushReplacement

Fix 4 prevents this by not adding navigate_to to the FCM payload when the value is null/empty, so the 4b scenario never occurs in production.

Fix 4: empty navigate_to comparison

Full Test Matrix (all 11 tests)

# Fix Test Result
1 Fix 2 Malformed /apps (no ID), warm start PASS
2 Fix 2 Valid /apps/id, warm start PASS
3 Fix 1 Cold start /apps (no ID) PASS
4 Fix 1 Cold start /apps/id PASS
5 Fix 1 Cold start /tasks/token PASS
6 — /unlimited navigation PASS
7 — omi:// scheme malformed PASS
8 — omi:// scheme cold start PASS
9 Fix 3 navigate_to: "/action-items" notification tap PASS
10 Fix 4 No navigate_to key in payload PASS
11 Fix 4 Empty string navigate_to (pre-fix behavior) Demonstrates bug

All 4 fixes validated end-to-end on Android emulator (API 35). Test code reverted — no test scaffolding in the commit.

@beastoin

Copy link
Copy Markdown
Collaborator Author

Real FCM Notification Test Results

Sent actual Firebase Cloud Messaging notifications to the emulator via Firebase Admin SDK (project: based-hardware-dev). This tests the full end-to-end flow: FCM → foreground handler → awesome_notifications → tap handler → navigation.

Fix 3: navigate_to: "/action-items" — PASS

Sent FCM with data: {navigate_to: "/action-items"}. Foreground handler created awesome_notification with navigate_to in payload. Tapped notification → app navigated to Action Items tab.

Fix 3 FCM: action-items navigation

Fix 4: No navigate_to in FCM data — PASS

Sent FCM without navigate_to field. Fix 4 ensures the awesome_notification payload stays clean (no empty navigate_to key). Tapped notification → app came to foreground at default tab. No disruptive pushReplacement navigation.

Logcat confirms: New action received (NotificationActionReceiver:36) — handler fired, but returned early since payload has no navigate_to key.

Fix 4 FCM: no navigate_to comparison

Setup details

  • FCM token from com.google.android.gms.appid.xml shared prefs on emulator
  • GMS had to be enabled (pm enable com.google.android.gms)
  • POST_NOTIFICATION permission granted via appops set + pm grant
  • Firebase Admin SDK (firebase-admin==7.1.0) for sending
  • Emulator: API 35, x86_64, software rendering

All 4 fixes now validated via real FCM + emulator e2e testing.

@beastoin beastoin left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@beastoin
beastoin merged commit 1f98214 into main Feb 14, 2026
1 check passed
@beastoin
beastoin deleted the fix/deep-link-routing-4799 branch February 14, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant