Skip to content

Commit 17ecd2f

Browse files
Keion Anvaripourfacebook-github-bot
Keion Anvaripour
authored andcommitted
Update RCTPushNotificationManager checkPermissions API to support iOS 10+
Summary: Changelog: [iOS][Changed] - Update `PushNotificationIOS.checkPermissions` to include iOS 10+ notification settings. `PushNotificationIOS.checkPermissions` is currently limited to only return: * alert :boolean * badge :boolean * sound :boolean That's has been a number of new properties since iOS 10 that we should support to improve pushability signal. This diff updates the logic to support 4 new available settings: * critical :boolean, * lockScreen :boolean, * notificationCenter :boolean, * autorizationStatus: number, Reviewed By: philIip Differential Revision: D35386762 fbshipit-source-id: 07c87de024756bc95a2c822ac35437ec76b3c903
1 parent 8dfbed7 commit 17ecd2f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Libraries/PushNotificationIOS/RCTPushNotificationManager.mm

+8-4
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
331331
RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback)
332332
{
333333
if (RCTRunningInAppExtension()) {
334-
callback(@[RCTSettingsDictForUNNotificationSettings(NO, NO, NO)]);
334+
callback(@[RCTSettingsDictForUNNotificationSettings(NO, NO, NO, NO, NO, NO, UNAuthorizationStatusNotDetermined)]);
335335
return;
336336
}
337337

@@ -343,11 +343,15 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
343343
static inline NSDictionary *RCTPromiseResolveValueForUNNotificationSettings(UNNotificationSettings* _Nonnull settings) {
344344
return RCTSettingsDictForUNNotificationSettings(settings.alertSetting == UNNotificationSettingEnabled,
345345
settings.badgeSetting == UNNotificationSettingEnabled,
346-
settings.soundSetting == UNNotificationSettingEnabled);
346+
settings.soundSetting == UNNotificationSettingEnabled,
347+
settings.criticalAlertSetting == UNNotificationSettingEnabled,
348+
settings.lockScreenSetting == UNNotificationSettingEnabled,
349+
settings.notificationCenterSetting == UNNotificationSettingEnabled,
350+
settings.authorizationStatus);
347351
}
348352

349-
static inline NSDictionary *RCTSettingsDictForUNNotificationSettings(BOOL alert, BOOL badge, BOOL sound) {
350-
return @{@"alert": @(alert), @"badge": @(badge), @"sound": @(sound)};
353+
static inline NSDictionary *RCTSettingsDictForUNNotificationSettings(BOOL alert, BOOL badge, BOOL sound, BOOL critical, BOOL lockScreen, BOOL notificationCenter, UNAuthorizationStatus authorizationStatus) {
354+
return @{@"alert": @(alert), @"badge": @(badge), @"sound": @(sound), @"critical": @(critical), @"lockScreen": @(lockScreen), @"notificationCenter": @(notificationCenter), @"authorizationStatus": @(authorizationStatus)};
351355
}
352356

353357
RCT_EXPORT_METHOD(presentLocalNotification:(JS::NativePushNotificationManagerIOS::Notification &)notification)

0 commit comments

Comments
 (0)