Athena — roomy-mobile/archive/changes/2026-01-05-implement-notifications/tasks/005-implement-push-notification-handler.md


skill-level: medior status: done

Task: Implement Push Notification Handler

End Goal

Flutter infrastructure that handles push notifications in foreground, background, and terminated states, including deep linking to relevant content.

Currently

  • No push notification handling exists
  • No deep linking from notifications
  • No notification display in foreground

Should

  • Foreground notifications display via flutter_local_notifications
  • Background/terminated notification taps navigate to relevant content
  • Deep link data is parsed from FCM payload
  • Navigation uses go_router for consistency

Constraints

  • [ ] Follow existing navigation patterns (go_router, CoreRouter)
  • [ ] Handle missing/deleted deep link targets gracefully
  • [ ] Support both iOS and Android notification behaviors
  • [ ] Initialize handlers before runApp

Acceptance Criteria

  • [ ] Foreground notifications display with title and body
  • [ ] Notification tap in foreground navigates to shopping list
  • [ ] Background notification tap launches app and navigates
  • [ ] Terminated app notification tap launches and navigates
  • [ ] Invalid deep links show error and navigate to fallback

Implementation Checklist

  • [ ] 5.1 Create PushNotificationHandler class
  • [ ] 5.2 Initialize FirebaseMessaging in main.dart before runApp
  • [ ] 5.3 Configure flutter_local_notifications for foreground display
  • [ ] 5.4 Implement onMessage handler for foreground notifications
  • [ ] 5.5 Implement onMessageOpenedApp handler for background taps
  • [ ] 5.6 Implement getInitialMessage handler for terminated taps
  • [ ] 5.7 Create deep link parser for FCM data payload
  • [ ] 5.8 Implement navigation to shopping list from deep link
  • [ ] 5.9 Handle invalid deep link targets with error toast
  • [ ] 5.10 Request notification permissions on first launch

Notes

  • FCM data payload format: { "route": "shopping_list", "shoppingListId": "abc123" }
  • iOS requires provisional authorization for notification permissions
  • Android 13+ requires runtime permission request
  • Use @pragma('vm:entry-point') for background message handler

Reacties

Nog geen reacties