Skip to content

Commit

Permalink
feat(firebase_messaging): retrieve timeSensitiveSetting for iOS 15+. (
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed May 3, 2022
1 parent e6e6a43 commit 14b38da
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
Expand Up @@ -688,6 +688,16 @@ + (NSDictionary *)NSDictionaryFromUNNotificationSettings:(UNNotificationSettings
}
}

NSNumber *timeSensitive = @-1;
if (@available(iOS 15.0, macOS 12.0, *)) {
if (settings.timeSensitiveSetting == UNNotificationSettingDisabled) {
timeSensitive = @0;
}
if (settings.timeSensitiveSetting == UNNotificationSettingEnabled) {
timeSensitive = @1;
}
}

NSNumber *showPreviews = @-1;
if (@available(iOS 11.0, *)) {
if (settings.showPreviewsSetting == UNShowPreviewsSettingNever) {
Expand Down Expand Up @@ -736,6 +746,8 @@ + (NSDictionary *)NSDictionaryFromUNNotificationSettings:(UNNotificationSettings
[FLTFirebaseMessagingPlugin NSNumberForUNNotificationSetting:settings.lockScreenSetting];
settingsDictionary[@"notificationCenter"] = [FLTFirebaseMessagingPlugin
NSNumberForUNNotificationSetting:settings.notificationCenterSetting];
settingsDictionary[@"timeSensitive"] = timeSensitive;

return settingsDictionary;
}

Expand Down
Expand Up @@ -17,6 +17,7 @@ class NotificationSettings {
required this.lockScreen,
required this.notificationCenter,
required this.showPreviews,
required this.timeSensitive,
required this.sound});

/// Whether or not messages containing a notification will alert the user.
Expand All @@ -33,6 +34,11 @@ class NotificationSettings {
/// The overall notification authorization status for the user.
final AuthorizationStatus authorizationStatus;

/// The setting that indicates the system treats the notification as time-sensitive.
///
/// Apple devices only.
final AppleNotificationSetting timeSensitive;

/// Whether or not messages containing a notification can update the application badge.
///
/// Apple devices only.
Expand Down
Expand Up @@ -132,6 +132,7 @@ NotificationSettings convertToNotificationSettings(Map<String, int> map) {
return NotificationSettings(
authorizationStatus:
convertToAuthorizationStatus(map['authorizationStatus']),
timeSensitive: convertToAppleNotificationSetting(map['timeSensitive']),
alert: convertToAppleNotificationSetting(map['alert']),
announcement: convertToAppleNotificationSetting(map['announcement']),
badge: convertToAppleNotificationSetting(map['badge']),
Expand All @@ -155,4 +156,5 @@ const NotificationSettings defaultNotificationSettings = NotificationSettings(
notificationCenter: AppleNotificationSetting.notSupported,
showPreviews: AppleShowPreviewSetting.notSupported,
sound: AppleNotificationSetting.notSupported,
timeSensitive: AppleNotificationSetting.notSupported,
);
Expand Up @@ -36,6 +36,7 @@ NotificationSettings getNotificationSettings(String? status) {
notificationCenter: AppleNotificationSetting.notSupported,
showPreviews: AppleShowPreviewSetting.notSupported,
sound: AppleNotificationSetting.notSupported,
timeSensitive: AppleNotificationSetting.notSupported,
);
}

Expand Down
Expand Up @@ -35,6 +35,7 @@ void main() {
expect(notification.badge, AppleNotificationSetting.notSupported);
expect(notification.carPlay, AppleNotificationSetting.notSupported);
expect(notification.lockScreen, AppleNotificationSetting.notSupported);
expect(notification.timeSensitive, AppleNotificationSetting.notSupported);
expect(
notification.notificationCenter,
AppleNotificationSetting.notSupported,
Expand Down

5 comments on commit 14b38da

@HlfDev
Copy link

@HlfDev HlfDev commented on 14b38da May 6, 2022

Choose a reason for hiding this comment

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

After this feature my flutter project was stopped building for IOS :(

20220506_182021

@melbanna40
Copy link

Choose a reason for hiding this comment

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

After this feature my flutter project was stopped building for IOS :(

20220506_182021

any solutions ?!

@PLPellegrini
Copy link

Choose a reason for hiding this comment

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

Seems to be affecting Flutter Web as well.

image

Additionally, pub doesn't recognize the latest version of firebase_messaging despite showing on the website

image
image

@russellwheatley
Copy link
Member Author

@russellwheatley russellwheatley commented on 14b38da May 12, 2022

Choose a reason for hiding this comment

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

Hey @PLPellegrini, @melbanna40, @HlfDev, thank you for the feedback. Do you mind sharing the particular device, iOS version and your dependencies (i.e. flutter pub deps -- --style=compact) on this issue, please πŸ™ ?

Also share what version of xcode you're running, please.

@Ekoios-Teddy
Copy link

Choose a reason for hiding this comment

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

@melbanna40 @HlfDev I updated Xcode version from 12.4 to 13.1 (maybe greater) and error is disappear.

Please sign in to comment.