Skip to content

fix(messaging,ios): report announcementSetting in iOS notification settings - #19018

Open
ReoAndo wants to merge 1 commit into
firebase:mainfrom
ReoAndo:fix/messaging-ios-notification-settings
Open

ReoAndo wants to merge 1 commit into
firebase:mainfrom
ReoAndo:fix/messaging-ios-notification-settings

Conversation

@ReoAndo

@ReoAndo ReoAndo commented Nov 27, 2026

Copy link
Copy Markdown

Description

On iOS, FLTFirebaseMessagingPlugin.NSDictionaryFromUNNotificationSettings: currently hardcodes settingsDictionary[@"announcement"] = @-1 (AppleNotificationSetting.notSupported) instead of reading UNNotificationSettings.announcementSetting, due to a legacy TODO from when the podspec targeted iOS 9.

firebase_messaging now requires iOS 15.0+ (both in firebase_messaging.podspec and Package.swift), and NotificationSettings.announcement is already wired up on the Dart side (convertToNotificationSettings maps -1, 0, and 1 to notSupported, disabled, and enabled).

This PR:

  • Maps settings.announcementSetting via NSNumberForUNNotificationSetting: on iOS 13+ inside #if TARGET_OS_OSX ... #else ... #endif, keeping @-1 on macOS where announcementSetting is API_UNAVAILABLE(macos, tvos) (matching the existing carPlaySetting guard).
  • Removes the now-unnecessary OCSimplifyInspectionLegacy diagnostic pragma around the announcement branch.
  • Replaces the sibling stale iOS 9 TODO in messagingRequestPermission: with a comment noting that UNAuthorizationOptionAnnouncement was deprecated in iOS 15.0 ("Announcement authorization is always included") and is unavailable on macOS, so it is intentionally not added to UNAuthorizationOptions.
  • Adds unit tests for convertToNotificationSettings (covering announcement enabled/disabled/notSupported states) and asserts settings.announcement in method_channel_messaging_test.dart.

Verification

  • dart format --output=none --set-exit-if-changed on modified Dart test files: passed.
  • clang-format --style=file --dry-run --Werror on edited lines of FLTFirebaseMessagingPlugin.m: passed.
  • dart analyze in firebase_messaging_platform_interface and firebase_messaging: no issues found.
  • flutter test in firebase_messaging_platform_interface (112/112) and firebase_messaging (22/22): all passed.
  • Verified #if TARGET_OS_OSX / @available(iOS 13.0, *) availability guards against Xcode UserNotifications/UNNotificationSettings.h for iOS 12.0, iOS 15.0, iOS Simulator 15.0, macOS 10.13, and macOS 11.0 with -Wall -Wextra -Werror.

Related Issues

None.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

…ttings

`NSDictionaryFromUNNotificationSettings:` previously hardcoded
`settingsDictionary[@"announcement"]` to `@-1` due to an obsolete iOS 9
deployment target TODO, even though `firebase_messaging` now requires
iOS 15.0+ and `NotificationSettings.announcement` is already exposed in
Dart.

Map `settings.announcementSetting` via `NSNumberForUNNotificationSetting:`
on iOS 13+, while keeping `@-1` on macOS (`TARGET_OS_OSX`) where
`UNNotificationSettings.announcementSetting` is `API_UNAVAILABLE(macos)`.
Also replace the stale iOS 9 TODO in `messagingRequestPermission:` with a
comment noting that `UNAuthorizationOptionAnnouncement` is deprecated in
iOS 15.0 (announcement authorization is always included) and unavailable
on macOS.

Co-Authored-By: Antigravity (Gemini 4 Neon) <noreply@google.com>
@google-cla

google-cla Bot commented Nov 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request cleans up deprecated announcement authorization options for iOS and macOS, updating the notification settings mapping to properly handle the announcement setting, and adds comprehensive unit tests to verify these conversions. The feedback suggests simplifying the iOS availability check in FLTFirebaseMessagingPlugin.m because the minimum deployment target is now iOS 15.0+, making the check redundant.

Comment on lines +1220 to +1229
#if TARGET_OS_OSX
settingsDictionary[@"announcement"] = @-1;
#else
if (@available(iOS 13.0, *)) {
// TODO not available in iOS9 deployment target - enable once iOS10+ deployment target specified
// in podspec. settingsDictionary[@"announcement"] =
// [FLTFirebaseMessagingPlugin NSNumberForUNNotificationSetting:settings.announcementSetting];
settingsDictionary[@"announcement"] = @-1;
settingsDictionary[@"announcement"] =
[FLTFirebaseMessagingPlugin NSNumberForUNNotificationSetting:settings.announcementSetting];
} else {
settingsDictionary[@"announcement"] = @-1;
}
#pragma clang diagnostic pop
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Since the minimum deployment target for firebase_messaging is now iOS 15.0+, the @available(iOS 13.0, *) check is always true on iOS. We can simplify this block by removing the redundant availability check and its else branch.

#if TARGET_OS_OSX
  settingsDictionary[@"announcement"] = @-1;
#else
  settingsDictionary[@"announcement"] =
      [FLTFirebaseMessagingPlugin NSNumberForUNNotificationSetting:settings.announcementSetting];
#endif

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant