Enable custom sound for local notification in PushNotificationIOS

Summary:
Add soundName property in NativePushNotificationManagerIOS JS module and deliver to native local notification API.
Changelog:
[iOS][Fixed] - Enable custom sound for local push notifications.

Reviewed By: RSNara

Differential Revision: D33898630

fbshipit-source-id: c6362032601f0f6d20479465ce1f0a84c450ea72
This commit is contained in:
Moses DeJong 2022-02-04 18:14:31 -08:00 коммит произвёл Facebook GitHub Bot
Родитель 3633a05299
Коммит eb19499484
2 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -29,6 +29,7 @@ type Notification = {|
+repeatInterval?: ?string,
+applicationIconBadgeNumber?: ?number,
+isSilent?: ?boolean,
+soundName?: ?string,
|};
export interface Spec extends TurboModule {

Просмотреть файл

@ -367,6 +367,9 @@ RCT_EXPORT_METHOD(presentLocalNotification:(JS::NativePushNotificationManagerIOS
}
if (notification.isSilent()) {
notificationDict[@"isSilent"] = @(*notification.isSilent());
if ([notificationDict[@"isSilent"] isEqualToNumber:@(NO)]) {
notificationDict[@"soundName"] = notification.soundName();
}
}
[RCTSharedApplication() presentLocalNotificationNow:[RCTConvert UILocalNotification:notificationDict]];
}
@ -388,6 +391,9 @@ RCT_EXPORT_METHOD(scheduleLocalNotification:(JS::NativePushNotificationManagerIO
}
if (notification.isSilent()) {
notificationDict[@"isSilent"] = @(*notification.isSilent());
if ([notificationDict[@"isSilent"] isEqualToNumber:@(NO)]) {
notificationDict[@"soundName"] = notification.soundName();
}
}
[RCTSharedApplication() scheduleLocalNotification:[RCTConvert UILocalNotification:notificationDict]];
}