Skip to content

Commit 5e319ca

Browse files
xilinXi Lin
andauthored
Fix boolean type when converting to js (#702)
In iOS, `@(YES)` is converted as `[NSNumber numberWithBool:]`, generating a `__NSCFBoolean` instance. While `@(1 == 1)` is converted as `[NSNumber numberWithInt:]`, generating a `__NSCFNumber` instance. And RN converter treat this differently. The first one becomes bool value, and the second one becomes numberic value. This PR makes sure the return value from native side will match type declaration in ts file `lib/src/interfaces/NotificationPermissions.ts`: ``` export interface NotificationPermissions { badge: boolean; alert: boolean; sound: boolean; } ``` Co-authored-by: Xi Lin <lxi@tesla.com>
1 parent d78e7a0 commit 5e319ca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/ios/RNNotificationCenter.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ - (void)isRegisteredForRemoteNotifications:(RCTPromiseResolveBlock)resolve {
7979
- (void)checkPermissions:(RCTPromiseResolveBlock)resolve {
8080
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
8181
resolve(@{
82-
@"badge": @(settings.badgeSetting == UNNotificationSettingEnabled),
83-
@"sound": @(settings.soundSetting == UNNotificationSettingEnabled),
84-
@"alert": @(settings.alertSetting == UNNotificationSettingEnabled),
82+
@"badge": [NSNumber numberWithBool:settings.badgeSetting == UNNotificationSettingEnabled],
83+
@"sound": [NSNumber numberWithBool:settings.soundSetting == UNNotificationSettingEnabled],
84+
@"alert": [NSNumber numberWithBool:settings.alertSetting == UNNotificationSettingEnabled],
8585
});
8686
}];
8787
}

0 commit comments

Comments
 (0)