Setup Push Notifications
Configure Account-profile Firebase Cloud Messaging (FCM) and local notification delivery for Flutter.
Scope
Flutter initializes local notification support for both profiles. FCM/device-token registration is Account-only; Guest mode never initializes FCM or syncs a device token.
1. Configure Firebase
- Create/select a project in the Firebase Console.
- Enable Firebase Cloud Messaging API (HTTP v1) as required by the current console.
- Register Android and iOS apps using the final identifiers in the generated project (the template currently uses
com.soewidiputra.flonlate.mobile). - From
mobile-app/, run:
firebase login
dart pub global activate flutterfire_cli
flutterfire configureSelect the intended Firebase project/platforms. This updates lib/firebase_options.dart and native Firebase configuration. Re-run it after changing package/bundle IDs; do not copy another app's config.
2. Configure Laravel sending
Generate a Firebase service-account key with messaging permission and store it outside Git at:
admin-panel/storage/app/firebase-auth.jsonNotificationSenderService reads exactly that path. The admin panel persists device tokens, notification history, and sends FCM messages from admin workflows.
3. Account registration flow
bootstrap/account_bootstrap.dart initializes Account FCM after the first frame:
- Permission is requested according to
NotificationConfig(the template uses the onboarding wizard). - Firebase returns the initial token and token-refresh events.
- Tokens are stored securely and posted to
POST /api/v1/app/device-tokenswhen a Sanctum token exists. - Foreground messages are displayed through
flutter_local_notifications. - Background handlers and app-open events are registered.
Local notification initialization itself requests no permission; the FCM/wizard path owns permission timing.
4. iOS and Android setup
- Android: add the final
google-services.json, notification permissions/channel configuration, and test Android 13+ permission behavior. - iOS: configure APNs authentication/capabilities in Firebase, Xcode, and EAS/signing credentials; test on a physical device.
- Keep the Firebase package/bundle IDs synchronized with
android/app,ios/Runner, andfirebase_options.dart.
5. Test delivery
- Complete the Account wizard permission step and confirm an FCM token is stored/synced.
- Send a test message from Firebase or Laravel admin.
- Confirm notification history and read/delete actions through
/api/v1/app/notifications. - Test foreground, background, terminated, denied-permission, token-refresh, logout, and Guest flows.
Notification-open handling currently logs/handles messages at the bootstrap/widget layer; it is not an arbitrary deep-link router. Add an explicit allowlisted navigation contract before trusting payload links.
Relevant files
lib/firebase_options.dartlib/config/notification_config.dartlib/helpers/notification.dartlib/helpers/notification_push.dartlib/bootstrap/account_bootstrap.dartlib/services/fcm_service.dartlib/services/notification_history_service.dart
