UNNotificationSound doesn't work properly

Hello everyone,

I set up critical alerts for my application with a custom sound, but when my app shows a critical alert there is a problem with an audio track when headphones plugged in.

Code Block
UNMutableNotificationContent *content =[UNMutableNotificationContent new];
content.sound = [UNNotificationSound criticalSoundNamed:@"alertMelody.wav"];

The audio track starts playing from the middle or later.
After that, I tested some cases with critical alerts but nothing changed.

I tried:
Code Block
1) content.sound = [UNNotificationSound criticalSoundNamed:@"alertMelody.wav" withAudioVolume:1.0];
2) content.sound = [UNNotificationSound defaultCriticalSoundWithAudioVolume:1.0];
3) content.sound = [UNNotificationSound defaultCriticalSound];


The only case when the audio track plays well through headphones is when I don't use critical alerts functionality.

Code Block
content.sound = [UNNotificationSound soundNamed:@"alertMelody.wav"];


Did anyone face this problem and if so how did you solve it?

Environment: iPhone XR, 14.3, XCode 12.3


UNNotificationSound doesn't work properly
 
 
Q