Skip to content

Commit

Permalink
FEAT: ios add permissions to check permissions (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielEliraz authored Aug 1, 2021
1 parent 945cfb0 commit 5a9d9fa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ class NotificationsExampleApp extends Component {
});
}

isRegistered() {
Notifications.isRegisteredForRemoteNotifications().then((registered) => {
console.warn(registered);
});
}

render() {
const notifications = this.state.notifications.map((notification, idx) =>
(
Expand Down Expand Up @@ -181,6 +187,7 @@ class NotificationsExampleApp extends Component {
}
<Button title={'Send local notification'} onPress={this.sendLocalNotification} testID={'sendLocalNotification'} />
<Button title={'Remove all delivered notifications'} onPress={this.removeAllDeliveredNotifications} />
<Button title={'Check registeration'} onPress={this.isRegistered} />
{notifications}
{openedNotifications}
</View>
Expand Down
2 changes: 2 additions & 0 deletions lib/ios/RNNotificationCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ - (void)checkPermissions:(RCTPromiseResolveBlock)resolve {
@"sound": [NSNumber numberWithBool:settings.soundSetting == UNNotificationSettingEnabled],
@"alert": [NSNumber numberWithBool:settings.alertSetting == UNNotificationSettingEnabled],
@"carPlay": [NSNumber numberWithBool:settings.carPlaySetting == UNNotificationSettingEnabled],
@"notificationCenter": [NSNumber numberWithBool:settings.notificationCenterSetting == UNNotificationSettingEnabled],
@"lockScreen": [NSNumber numberWithBool:settings.lockScreenSetting == UNNotificationSettingEnabled],
}];
if (@available(iOS 12.0, *)) {
allSettings[@"criticalAlert"] = [NSNumber numberWithBool:settings.criticalAlertSetting == UNNotificationSettingEnabled];
Expand Down
2 changes: 2 additions & 0 deletions lib/src/commands/Commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ describe('Commands', () => {
providesAppNotificationSettings: false,
provisional: false,
announcement: false,
notificationCenter: true,
lockScreen: false,
};
when(mockedNativeCommandsSender.checkPermissions()).thenResolve(
expectedPermissions
Expand Down
2 changes: 2 additions & 0 deletions lib/src/interfaces/NotificationPermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export interface NotificationPermissions extends NotificationPermissionOptions
badge: boolean;
alert: boolean;
sound: boolean;
notificationCenter: boolean;
lockScreen: boolean;
}

0 comments on commit 5a9d9fa

Please sign in to comment.