Is there an existing issue for this?
Which plugins are affected?
Messaging
Which platforms are affected?
iOS
Description
On iOS, FLTFirebaseMessagingPlugin calls the UNUserNotificationCenter completion handler for
every foreground notification, including notifications created by other plugins. Since the
default presentation options are empty, iOS drops those notifications: nothing is shown and
they are not even stored as delivered. No error surfaces anywhere — show() succeeds.
This happens whenever the app has a UNUserNotificationCenterDelegate that conforms to
FlutterAppLifeCycleProvider, i.e. any FlutterAppDelegate, because the plugin then keeps
_originalNotificationCenterDelegate nil:
if ([currentDelegate conformsToProtocol:@protocol(FlutterAppLifeCycleProvider)]) {
shouldReplaceDelegate = NO;
}
and later takes the else branch of willPresentNotification: regardless of whose notification
it is:
} else {
UNNotificationPresentationOptions presentationOptions = UNNotificationPresentationOptionNone;
NSDictionary *persistedOptions = ...;
...
completionHandler(presentationOptions);
}
The gcm.message_id check above is only used to emit Messaging#onMessage, not for the
presentation decision.
flutter_local_notifications handles the same situation correctly and leaves the completion
handler alone when the notification is not its own:
if (![self isAFlutterLocalNotification:notification.request.content.userInfo]) {
return;
}
Suggested fix: return early from willPresentNotification: when gcm.message_id is absent and the
plugin has not replaced the delegate, leaving the decision to the owner of the notification.
Both code paths are old — the conformsToProtocol check first shipped in 11.4.2 (June 2022) and
the unconditional completionHandler call exists at least since 9.0.0 (February 2021). What
changed is the UIScene lifecycle, default since Flutter 3.41.
Reproducing the issue
Minimal reproduction, no Firebase project or credentials required:
https://github.com/terekhovm/fcm_issue
- flutter run on an iOS device
- allow notifications
- keep the app in the foreground and press "Show local notification"
Expected: a banner appears, the screen reports "delivered notifications: 1".
Actual: nothing appears, the screen reports "delivered notifications: 0".
Removing firebase_messaging from pubspec.yaml — nothing else — makes it work.
The app is a stock flutter create project plus the single line that
flutter_local_notifications' iOS setup asks for.
Firebase Core version
4.15.0
Flutter Version
3.47.5
Relevant Log Output
No output: show() returns successfully and nothing is logged on either side.
Flutter dependencies
firebase_core: ^4.15.0
firebase_messaging: ^16.7.0
flutter_local_notifications: ^22.3.1
Additional context and comments
Related but different: #18204 was closed as a plugin version issue, and
flutter/flutter#185048 as the same. Neither covers the plugin answering for foreign
notifications.
Workaround for apps hitting this: answer in the app's own AppDelegate — handle local
notifications there and forward remote ones to super so Messaging#onMessage keeps firing.
Is there an existing issue for this?
Which plugins are affected?
Messaging
Which platforms are affected?
iOS
Description
On iOS, FLTFirebaseMessagingPlugin calls the UNUserNotificationCenter completion handler for
every foreground notification, including notifications created by other plugins. Since the
default presentation options are empty, iOS drops those notifications: nothing is shown and
they are not even stored as delivered. No error surfaces anywhere — show() succeeds.
This happens whenever the app has a UNUserNotificationCenterDelegate that conforms to
FlutterAppLifeCycleProvider, i.e. any FlutterAppDelegate, because the plugin then keeps
_originalNotificationCenterDelegate nil:
and later takes the else branch of willPresentNotification: regardless of whose notification
it is:
The gcm.message_id check above is only used to emit Messaging#onMessage, not for the
presentation decision.
flutter_local_notifications handles the same situation correctly and leaves the completion
handler alone when the notification is not its own:
Suggested fix: return early from willPresentNotification: when gcm.message_id is absent and the
plugin has not replaced the delegate, leaving the decision to the owner of the notification.
Both code paths are old — the conformsToProtocol check first shipped in 11.4.2 (June 2022) and
the unconditional completionHandler call exists at least since 9.0.0 (February 2021). What
changed is the UIScene lifecycle, default since Flutter 3.41.
Reproducing the issue
Minimal reproduction, no Firebase project or credentials required:
https://github.com/terekhovm/fcm_issue
Expected: a banner appears, the screen reports "delivered notifications: 1".
Actual: nothing appears, the screen reports "delivered notifications: 0".
Removing firebase_messaging from pubspec.yaml — nothing else — makes it work.
The app is a stock
flutter createproject plus the single line thatflutter_local_notifications' iOS setup asks for.
Firebase Core version
4.15.0
Flutter Version
3.47.5
Relevant Log Output
No output: show() returns successfully and nothing is logged on either side.Flutter dependencies
firebase_core: ^4.15.0
firebase_messaging: ^16.7.0
flutter_local_notifications: ^22.3.1
Additional context and comments
Related but different: #18204 was closed as a plugin version issue, and
flutter/flutter#185048 as the same. Neither covers the plugin answering for foreign
notifications.
Workaround for apps hitting this: answer in the app's own AppDelegate — handle local
notifications there and forward remote ones to super so Messaging#onMessage keeps firing.