Repository navigation
Conversation
…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>
|
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. |
There was a problem hiding this comment.
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.
| #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 |
There was a problem hiding this comment.
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
Description
On iOS,
FLTFirebaseMessagingPlugin.NSDictionaryFromUNNotificationSettings:currently hardcodessettingsDictionary[@"announcement"] = @-1(AppleNotificationSetting.notSupported) instead of readingUNNotificationSettings.announcementSetting, due to a legacyTODOfrom when the podspec targeted iOS 9.firebase_messagingnow requires iOS 15.0+ (both infirebase_messaging.podspecandPackage.swift), andNotificationSettings.announcementis already wired up on the Dart side (convertToNotificationSettingsmaps-1,0, and1tonotSupported,disabled, andenabled).This PR:
settings.announcementSettingviaNSNumberForUNNotificationSetting:on iOS 13+ inside#if TARGET_OS_OSX ... #else ... #endif, keeping@-1on macOS whereannouncementSettingisAPI_UNAVAILABLE(macos, tvos)(matching the existingcarPlaySettingguard).OCSimplifyInspectionLegacydiagnostic pragma around theannouncementbranch.TODOinmessagingRequestPermission:with a comment noting thatUNAuthorizationOptionAnnouncementwas deprecated in iOS 15.0 ("Announcement authorization is always included") and is unavailable on macOS, so it is intentionally not added toUNAuthorizationOptions.convertToNotificationSettings(coveringannouncementenabled/disabled/notSupported states) and assertssettings.announcementinmethod_channel_messaging_test.dart.Verification
dart format --output=none --set-exit-if-changedon modified Dart test files: passed.clang-format --style=file --dry-run --Werroron edited lines ofFLTFirebaseMessagingPlugin.m: passed.dart analyzeinfirebase_messaging_platform_interfaceandfirebase_messaging: no issues found.flutter testinfirebase_messaging_platform_interface(112/112) andfirebase_messaging(22/22): all passed.#if TARGET_OS_OSX/@available(iOS 13.0, *)availability guards against XcodeUserNotifications/UNNotificationSettings.hfor 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.yamland changelogs is not required.///).melos run analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?