Skip to content

Commit

Permalink
Added support for checking if lockScreen and notificationCenter setti…
Browse files Browse the repository at this point in the history
…ngs are enabled (#142)
  • Loading branch information
alexhernandez authored Jul 4, 2020
1 parent aa69af1 commit 947b300
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ See what push permissions are currently enabled.
- `alert` :boolean
- `badge` :boolean
- `sound` :boolean
- `lockScreen` :boolean
- `notificationCenter` :boolean

---

Expand Down
12 changes: 7 additions & 5 deletions ios/RNCPushNotificationIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback)
{
if (RCTRunningInAppExtension()) {
callback(@[RCTSettingsDictForUNNotificationSettings(NO, NO, NO)]);
callback(@[RCTSettingsDictForUNNotificationSettings(NO, NO, NO, NO, NO)]);
return;
}

Expand All @@ -354,12 +354,14 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
static inline NSDictionary *RCTPromiseResolveValueForUNNotificationSettings(UNNotificationSettings* _Nonnull settings) {
return RCTSettingsDictForUNNotificationSettings(settings.alertSetting == UNNotificationSettingEnabled,
settings.badgeSetting == UNNotificationSettingEnabled,
settings.soundSetting == UNNotificationSettingEnabled);
settings.soundSetting == UNNotificationSettingEnabled,
settings.lockScreenSetting == UNNotificationSettingEnabled,
settings.notificationCenterSetting == UNNotificationSettingEnabled);
}

static inline NSDictionary *RCTSettingsDictForUNNotificationSettings(BOOL alert, BOOL badge, BOOL sound) {
return @{@"alert": @(alert), @"badge": @(badge), @"sound": @(sound)};
}
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)};
}


RCT_EXPORT_METHOD(presentLocalNotification:(UILocalNotification *)notification)
Expand Down

0 comments on commit 947b300

Please sign in to comment.