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.