firebase_messaging_handler 1.0.3
firebase_messaging_handler: ^1.0.3 copied to clipboard
Production-ready Firebase Cloud Messaging for Flutter with a unified click stream, notification inbox, in-app messaging, diagnostics, badges, and scheduling.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.3 - 2026-03-08 #
Added #
- Swift Package Manager (SPM) support —
ios/Package.swiftadded; iOS plugin now resolves via SPM in addition to CocoaPods
Changed #
- WASM compatibility — replaced
universal_htmldependency withdart:js_interop-based abstraction; package now passes WASM analysis - iOS native stub simplified — removed unused
FirebaseCore/FirebaseMessagingimports (FCM is handled entirely byfirebase_messaging)
1.0.2 - 2026-03-08 #
Changed #
flutter_local_notificationslower bound tightened to^21.0.0— aligns constraint with the v21 named parameter API the package actually requires
1.0.1 - 2026-03-08 #
Changed #
flutter_local_notificationsconstraint widened to>=18.0.1 <22.0.0— now fully compatible with v21 (named parameter API)
Fixed #
- Updated all
flutter_local_notificationscall sites to v21 named parameter API (show,initialize,zonedSchedule,periodicallyShow,cancel) - Removed deprecated
uiLocalNotificationDateInterpretationparameter fromzonedSchedulecalls - Removed broken CI and codecov badges from README
1.0.0 - 2026-03-08 #
Added #
- Android & macOS platform support — both platforms now fully declared
lastTokenErroronFirebaseMessagingHandler.instance— surfaces the exact reason an FCM token could not be retrieved (e.g. APNs not configured, simulator)
Changed #
flutter_local_notificationsconstraint widened to>=18.0.1 <22.0.0— compatible with v19, v20, and v21- FCM token failures now return
nullinstead of silent mock tokens — checklastTokenErrorfor the reason
0.1.1-beta.1 #
Added #
- Modular architecture — complete rewrite into
core/managers,core/services,core/interfaces,core/utilslayers; clean separation of concerns - Unified handler API — single
Future<bool> Function(NormalizedMessage, NotificationLifecycle)callback that works across foreground, background, and terminated states without manual@pragmawiring NormalizedMessagemodel — consistenttitle,body,imageUrl,data,actions,receivedAt,origin,channelId,rawacross all lifecyclesNotificationLifecycleenum —foreground,background,terminated,resume,initial- Auto initial-notification emission — terminated-launch notifications automatically queued and emitted onto the unified click stream; opt-out available
- In-app messaging engine — silent FCM push (
fcmh_inappkey) triggers in-app templates registered viaregisterInAppNotificationTemplates builtin_genericrenderer — seven layout variants driven bylayout:key:dialog,banner(top/bottom),bottom_sheet,snackbar,tooltip,carousel,html_modal- Frequency caps and quiet hours — lifecycle-aware presentation throttling; configurable quiet windows
- Notification inbox —
NotificationInboxViewwidget with swipe-to-delete, mark-as-read, pagination;NotificationInboxStorageInterfacefor swappable persistence (SharedPrefs default + in-memory test impl) BridgingPayloadValidator— validates data-only payloads before bridging; rejects missingtitle/body, type errors, script injection; incrementsdiagnostics.invalidPayloadCount- Data-only bridging — configurable key mapping to promote silent payloads to local notifications; web suppression with once-per-session log
BadgeManager— unified badge abstraction overflutter_local_notifications(iOS) and notification channels (Android); local persistencePermissionWizardService—requestAllPermissions()with richPermissionWizardResultcovering Android (POST_NOTIFICATIONS) and iOS (alert/badge/sound/provisional)runDiagnostics()onFirebaseMessagingHandler.instance— returnsNotificationDiagnosticsResultwith permission status, token availability, badge support, background handler registration state, pending count, web permission, invalid payload countbin/setup.dartdoctor script — checksgoogle-services.json,GoogleService-Info.plist, AndroidManifest permissions; auto-patchesINTERNETandPOST_NOTIFICATIONS- Smart default channel — auto-creates a high-importance channel at init if none exist, preventing silent foreground notifications on Android
- Background dispatcher helper —
@pragma('vm:entry-point')-safe entry point; hydrates storage and queues before user handler runs FmhAnalyticsService— pluggable analytics callback tracking received, click, action, schedule, and token eventsInAppOverlayHost/InAppOverlayController— managed overlay stack for presenting in-app templates above all other widgetsBuiltInInAppTemplates.versionPrompt— pre-built app update prompt templateNotificationInboxView— full inbox widget with theming knobs, avatar/image support, swipe gestures, empty state, and action chips- Pending click queue — click events delivered to late stream subscribers (background/terminated taps before
listencall) - Web platform registration —
FirebaseMessagingHandlerWebDart plugin class viaflutter_web_plugins - Platform utilities — conditional
platform_utils.dartwith IO and web stubs;js_compat.dartfor web JS interop - New tests — click-stream queue delivery,
BridgingPayloadValidatoraccept/reject matrix,InboxStorageServiceupsert/paging/markRead/delete, golden harness (alchemist) flutter_widget_from_html_coredependency forhtml_modaltemplate layouttimezonedependency for accurate scheduled notification delivery
Changed #
- Public API facade (
FirebaseMessagingHandler) fully preserved; all new APIs are additive - Example app rebuilt as FCM Showcase — scenario inspector, activity timeline, inbox screen, template trigger demos, APNs setup guidance, diagnostics sheet, token copy overlay
- README restructured with feature-by-feature walkthrough, quick-start, and payload cookbook
Fixed #
- Foreground click stream on Android — events were silently dropped when the stream had no listener at the time of tap
- iOS duplicate foreground notifications — the package now prevents showing a local notification when Firebase already delivered it in the foreground
- iOS initial message detection — added 100 ms retry for iOS timing edge case on cold start
app_badger/flutter_app_badgernamespace conflicts — removed; badge management now handled viaflutter_local_notificationsand platform channel fallback
0.1.0 #
Added #
subscribeToTopic(String topic)— subscribe to an FCM topicunsubscribeFromTopic(String topic)— unsubscribe from a topicunsubscribeFromAllTopics()— bulk topic unsubscriptionNotificationStreamExtensions— stream utility extensions- Terminated-state notification fix — initial message now correctly retrieved on cold start via
getInitialMessage()
Changed #
- Removed native Android and iOS plugin stubs — package now relies entirely on
firebase_messagingandflutter_local_notificationsfor native work (pure-Dart approach) firebase_messagingminimum constraint raised to>=15.1.4- Dropped Linux, macOS, Windows example targets — focused on Android and iOS
Fixed #
- Click stream not delivering terminated-state notification on first launch
- Example app not handling notification tap navigation correctly
0.0.8 #
Fixed #
- Dependency version constraints causing resolution failures with newer
firebase_messagingandflutter_local_notificationsreleases
0.0.7 #
0.0.5 #
Added #
- Stream disposal —
dispose()now properly closes the notification stream controller and cancels all subscriptions
0.0.3 #
0.0.2 #
0.0.1 #
Added #
- Initial release
FirebaseMessagingHandlersingleton withinit()— sets up FCM, requests permissions, creates Android notification channels, returns a click streamNotificationDatamodel — wraps incoming FCM payloads withtitle,body,payload,typeNotificationChannelData— configurable Android notification channel (importance, priority, sound, vibration, lights)NotificationImportanceEnum,NotificationPriorityEnum,NotificationTypeEnum— type-safe enumsAndroidNotificationChannelExtensions— convertsNotificationChannelDatatoflutter_local_notificationschannel objectsFirebaseMessagingHandlerSharedPreferences— local storage for FCM token caching- Foreground and background notification handling via
firebase_messaging - Local notification display via
flutter_local_notifications - Example app demonstrating basic setup and notification receipt