Skip to content

FEAT: ios add permissions to check permissions #762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}