-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Is there an existing issue for this?
- I have searched the existing issues.
Which plugins are affected?
Messaging
Which platforms are affected?
iOS
Description
Summary
Since firebase_messaging 15.1.4 (PR #13572) we observed that on any iOS device the Flutter FirebaseMessaging.onMessage.listen callback can be suppressed when multiple foreground notifications reuse the same UNNotificationRequest.identifier (commonly when using apns-collapse-id to update/replace a notification).
Related issue: #17028
Likely regression introduced by: #13572
Changelog (15.1.4 includes #13572): https://pub.dev/packages/firebase_messaging/changelog#1514
Patch/diff: https://github.com/firebase/flutterfire/pull/13572.patch
Important note about reproducibility
- Reproducible on any iOS version: we can reliably reproduce the issue (see steps below).
- and the plugin currently performs a foreground āduplicateā filter based on
UNNotificationRequest.identifier, which is not safe whenapns-collapse-idis used for legitimate updates.
Expected behavior
When the app is in the foreground, every incoming FCM message should trigger FirebaseMessaging.onMessage.listen,
even if multiple messages share the same apns-collapse-id (the OS can still collapse/replace the visible notification).
Actual behavior (any iOS device)
Only the first notification triggers onMessage. Subsequent notifications that reuse the same collapse ID / request identifier:
- are delivered,
- may appear/rewrite in Notification Center as expected,
- but do not trigger
FirebaseMessaging.onMessage.listen.
Suspected cause (regression from #13572)
PR #13572 introduced a foreground āduplicate notificationā workaround for iOS 18 that:
- reads
notification.request.identifier, - skips invoking
"Messaging#onMessage"whenidentifier == _foregroundUniqueIdentifier, - then sets
_foregroundUniqueIdentifier = identifier.
When apns-collapse-id is used, iOS can map it to the UNNotificationRequest.identifier, so updates with the same collapse ID end up with the same identifier and get filtered out by the plugin.
Reproducing the issue
Repro steps
- Use
firebase_messaging15.1.4+ on iOS. - Register a listener:
FirebaseMessaging.onMessage.listen((msg) { debugPrint('onMessage: ${msg.messageId} data=${msg.data}'); });
Firebase Core version
4.3.0
Flutter Version
3.32.8
Relevant Log Output
Flutter dependencies
Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.
Additional context and comments
No response