Custom Notification Sounds is not working in the foreground on iOS 15 / 16

Last day, I had looked up and experiment about custom notification sound for remote notification. And I found the issue what about the custom sound didn't play in foreground on iOS 15 and iOS 16, but it worked on iOS 11.

After experiment, I looked up the interesting for this, when I added a breakpoint at "UNUserNotificationCenterDelegate.userNotificationCenter:willPresentNotification", like bellow, and the sound had played after left to the breakpoint.

-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
// breakpoint here
 completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound);
}
code-block

The behavior was reproduced with all of the iPhones (iOS15-16) I could borrow from my company.

Custom Notification Sounds is not working in the foreground on iOS 15 / 16
 
 
Q