diff --git a/README.md b/README.md index 7eaee9d7b..cfdab16ee 100644 --- a/README.md +++ b/README.md @@ -469,7 +469,9 @@ See what push permissions are currently enabled. - `sound` :boolean - `lockScreen` :boolean - `notificationCenter` :boolean +- `authorizationStatus` :AuthorizationStatus + For a list of possible values of `authorizationStatus`, see `PushNotificationIOS.AuthorizationStatus`. For their meanings, refer to https://developer.apple.com/documentation/usernotifications/unauthorizationstatus --- ### `getInitialNotification()` diff --git a/index.d.ts b/index.d.ts index ddfacbfee..0f8792663 100644 --- a/index.d.ts +++ b/index.d.ts @@ -8,6 +8,13 @@ export interface FetchResult { ResultFailed: 'UIBackgroundFetchResultFailed'; } +export interface AuthorizationStatus { + UNAuthorizationStatusNotDetermined: 0; + UNAuthorizationStatusDenied: 1; + UNAuthorizationStatusAuthorized: 2; + UNAuthorizationStatusProvisional: 3; +} + export interface PushNotification { /** * An alias for `getAlert` to get the notification's main message string @@ -148,6 +155,9 @@ export interface PushNotificationPermissions { alert?: boolean; badge?: boolean; sound?: boolean; + lockScreen?: boolean; + notificationCenter?: boolean; + authorizationStatus?: AuthorizationStatus; } export type PushNotificationEventName = @@ -168,6 +178,11 @@ export interface PushNotificationIOSStatic { * For a list of possible values, see `PushNotificationIOS.FetchResult`. */ FetchResult: FetchResult; + /** + * Authorization status of notification settings + * For a list of possible values, see `PushNotificationIOS.AuthorizationStatus`. + */ + AuthorizationStatus: AuthorizationStatus; /** * Schedules the localNotification for immediate presentation. * details is an object containing: diff --git a/ios/RNCPushNotificationIOS.m b/ios/RNCPushNotificationIOS.m index 1b9630f07..2bc524eb5 100644 --- a/ios/RNCPushNotificationIOS.m +++ b/ios/RNCPushNotificationIOS.m @@ -356,7 +356,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback) { if (RCTRunningInAppExtension()) { - callback(@[RCTSettingsDictForUNNotificationSettings(NO, NO, NO, NO, NO)]); + callback(@[RCTSettingsDictForUNNotificationSettings(NO, NO, NO, NO, NO, UNAuthorizationStatusNotDetermined)]); return; } @@ -370,11 +370,12 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification settings.badgeSetting == UNNotificationSettingEnabled, settings.soundSetting == UNNotificationSettingEnabled, settings.lockScreenSetting == UNNotificationSettingEnabled, - settings.notificationCenterSetting == UNNotificationSettingEnabled); + settings.notificationCenterSetting == UNNotificationSettingEnabled, + settings.authorizationStatus); } -static inline NSDictionary *RCTSettingsDictForUNNotificationSettings(BOOL alert, BOOL badge, BOOL sound, BOOL lockScreen, BOOL notificationCenter) { - return @{@"alert": @(alert), @"badge": @(badge), @"sound": @(sound), @"lockScreen": @(lockScreen), @"notificationCenter": @(notificationCenter)}; +static inline NSDictionary *RCTSettingsDictForUNNotificationSettings(BOOL alert, BOOL badge, BOOL sound, BOOL lockScreen, BOOL notificationCenter, UNAuthorizationStatus authorizationStatus) { + return @{@"alert": @(alert), @"badge": @(badge), @"sound": @(sound), @"lockScreen": @(lockScreen), @"notificationCenter": @(notificationCenter), @"authorizationStatus": @(authorizationStatus)}; } diff --git a/js/index.js b/js/index.js index e556d3587..e7de8ed04 100644 --- a/js/index.js +++ b/js/index.js @@ -32,6 +32,13 @@ export type FetchResult = { ResultFailed: string, }; +export type AuthorizationStatus = { + UNAuthorizationStatusNotDetermined: 0, + UNAuthorizationStatusDenied: 1, + UNAuthorizationStatusAuthorized: 2, + UNAuthorizationStatusProvisional: 3, +}; + /** * An event emitted by PushNotificationIOS. */ @@ -86,6 +93,13 @@ class PushNotificationIOS { ResultFailed: 'UIBackgroundFetchResultFailed', }; + static AuthorizationStatus: AuthorizationStatus = { + UNAuthorizationStatusNotDetermined: 0, + UNAuthorizationStatusDenied: 1, + UNAuthorizationStatusAuthorized: 2, + UNAuthorizationStatusProvisional: 3, + }; + /** * Schedules the localNotification for immediate presentation. *