-
Notifications
You must be signed in to change notification settings - Fork 20
Fix push notification tap not navigating to trade detail screen #445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…inated states - Initialize notifications in background isolate for proper tap handling - Add notification tap handlers for background and terminated app states - Navigate to order detail screen when notification contains order_id - Add fallback navigation to notifications screen when no order ID present - Handle initial message when app launches from terminated state via notification - Improve error handling and logging for navigation
Add mounted check after async getNotificationLaunchOrderId() call to prevent navigation on disposed widget when app is launched from notification tap.
WalkthroughIntroduces notification-driven app navigation for terminated state launches. When users tap a notification, the app fetches the notification's orderId and navigates directly to the corresponding trade detail page upon initialization. Changes
Sequence DiagramsequenceDiagram
participant App as App Initialization
participant Router as GoRouter
participant BGService as Background<br/>Notification Service
participant System as System Notification
App->>Router: Router available?
Router-->>App: navigatorKey ready
App->>BGService: getNotificationLaunchOrderId()
BGService->>System: Query notification launch details
System-->>BGService: Notification payload (orderId)
BGService-->>App: Return orderId (or null)
alt Notification orderId present
App->>Router: Navigate to /trade_detail/{orderId}
else No notification
App->>App: Mark handled, wait for user action
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
When i test it only works well for notifications of these statuses: |
mostronator
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Clean fix.
The root cause was clear: GoRouter was creating its own GlobalKey<NavigatorState>() instead of sharing MostroApp.navigatorKey, so currentContext was always null in notification tap handlers.
Key changes look correct:
- Navigator key wiring —
navigatorKey: MostroApp.navigatorKeyincreateRouter()✅ - Terminated-state launch —
getNotificationLaunchOrderId()viagetNotificationAppLaunchDetails()handles cold-start from notification ✅ _onNotificationTaplogic — fixed inverted null check + properly routes to/trade_detail/$orderIdwhen payload exists ✅_notificationLaunchHandledguard — prevents duplicate navigation on rebuilds ✅
The addPostFrameCallback in build is fine since it's gated by _notificationLaunchHandled flag.
The root cause was MostroApp.navigatorKey not being wired into GoRouter — it created a separate GlobalKey, so the navigator context was always
null when handling notification taps.
Changes:
Summary by CodeRabbit