Skip to content

Commit

Permalink
Enable custom sound for local notification in PushNotificationIOS
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Moses DeJong authored and facebook-github-bot committed Feb 5, 2022
1 parent 3633a05 commit eb19499
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Notification = {|
+repeatInterval?: ?string,
+applicationIconBadgeNumber?: ?number,
+isSilent?: ?boolean,
+soundName?: ?string,
|};

export interface Spec extends TurboModule {
Expand Down
6 changes: 6 additions & 0 deletions Libraries/PushNotificationIOS/RCTPushNotificationManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
}
if (notification.isSilent()) {
notificationDict[@"isSilent"] = @(*notification.isSilent());
if ([notificationDict[@"isSilent"] isEqualToNumber:@(NO)]) {
notificationDict[@"soundName"] = notification.soundName();
}
}
[RCTSharedApplication() presentLocalNotificationNow:[RCTConvert UILocalNotification:notificationDict]];
}
Expand All @@ -388,6 +391,9 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
}
if (notification.isSilent()) {
notificationDict[@"isSilent"] = @(*notification.isSilent());
if ([notificationDict[@"isSilent"] isEqualToNumber:@(NO)]) {
notificationDict[@"soundName"] = notification.soundName();
}
}
[RCTSharedApplication() scheduleLocalNotification:[RCTConvert UILocalNotification:notificationDict]];
}
Expand Down

0 comments on commit eb19499

Please sign in to comment.