Skip to content

Commit eb19499

Browse files
Moses DeJongfacebook-github-bot
Moses DeJong
authored andcommitted
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
1 parent 3633a05 commit eb19499

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Notification = {|
2929
+repeatInterval?: ?string,
3030
+applicationIconBadgeNumber?: ?number,
3131
+isSilent?: ?boolean,
32+
+soundName?: ?string,
3233
|};
3334

3435
export interface Spec extends TurboModule {

Libraries/PushNotificationIOS/RCTPushNotificationManager.mm

+6
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
367367
}
368368
if (notification.isSilent()) {
369369
notificationDict[@"isSilent"] = @(*notification.isSilent());
370+
if ([notificationDict[@"isSilent"] isEqualToNumber:@(NO)]) {
371+
notificationDict[@"soundName"] = notification.soundName();
372+
}
370373
}
371374
[RCTSharedApplication() presentLocalNotificationNow:[RCTConvert UILocalNotification:notificationDict]];
372375
}
@@ -388,6 +391,9 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
388391
}
389392
if (notification.isSilent()) {
390393
notificationDict[@"isSilent"] = @(*notification.isSilent());
394+
if ([notificationDict[@"isSilent"] isEqualToNumber:@(NO)]) {
395+
notificationDict[@"soundName"] = notification.soundName();
396+
}
391397
}
392398
[RCTSharedApplication() scheduleLocalNotification:[RCTConvert UILocalNotification:notificationDict]];
393399
}

0 commit comments

Comments
 (0)