Skip to content

Commit 5a9d9fa

Browse files
authored
FEAT: ios add permissions to check permissions (#762)
1 parent 945cfb0 commit 5a9d9fa

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

example/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ class NotificationsExampleApp extends Component {
154154
});
155155
}
156156

157+
isRegistered() {
158+
Notifications.isRegisteredForRemoteNotifications().then((registered) => {
159+
console.warn(registered);
160+
});
161+
}
162+
157163
render() {
158164
const notifications = this.state.notifications.map((notification, idx) =>
159165
(
@@ -181,6 +187,7 @@ class NotificationsExampleApp extends Component {
181187
}
182188
<Button title={'Send local notification'} onPress={this.sendLocalNotification} testID={'sendLocalNotification'} />
183189
<Button title={'Remove all delivered notifications'} onPress={this.removeAllDeliveredNotifications} />
190+
<Button title={'Check registeration'} onPress={this.isRegistered} />
184191
{notifications}
185192
{openedNotifications}
186193
</View>

lib/ios/RNNotificationCenter.m

+2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ - (void)checkPermissions:(RCTPromiseResolveBlock)resolve {
109109
@"sound": [NSNumber numberWithBool:settings.soundSetting == UNNotificationSettingEnabled],
110110
@"alert": [NSNumber numberWithBool:settings.alertSetting == UNNotificationSettingEnabled],
111111
@"carPlay": [NSNumber numberWithBool:settings.carPlaySetting == UNNotificationSettingEnabled],
112+
@"notificationCenter": [NSNumber numberWithBool:settings.notificationCenterSetting == UNNotificationSettingEnabled],
113+
@"lockScreen": [NSNumber numberWithBool:settings.lockScreenSetting == UNNotificationSettingEnabled],
112114
}];
113115
if (@available(iOS 12.0, *)) {
114116
allSettings[@"criticalAlert"] = [NSNumber numberWithBool:settings.criticalAlertSetting == UNNotificationSettingEnabled];

lib/src/commands/Commands.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ describe('Commands', () => {
203203
providesAppNotificationSettings: false,
204204
provisional: false,
205205
announcement: false,
206+
notificationCenter: true,
207+
lockScreen: false,
206208
};
207209
when(mockedNativeCommandsSender.checkPermissions()).thenResolve(
208210
expectedPermissions

lib/src/interfaces/NotificationPermissions.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ export interface NotificationPermissions extends NotificationPermissionOptions
99
badge: boolean;
1010
alert: boolean;
1111
sound: boolean;
12+
notificationCenter: boolean;
13+
lockScreen: boolean;
1214
}

0 commit comments

Comments
 (0)