Why is my UILocalNotification not playing sound?

It drives me crazy, I believe that by that time I was trying to use all possible methods all the time, but my phone still decides to be silent. I just want it to sound now when I present a local notification. UILocalNotificationDefaultSoundNameNeither the user sounds that I added to my application package currently work . I wrote a simple countdown application that uses presentLocalNotification:when the countdown ends.

- (void)showLocalNotification
{
   UILocalNotification *alarmNotification = [[UILocalNotification alloc] init];
   alarmNotification.alertBody = [NSString stringWithFormat:@"fired at: %@", [NSDate date]];
   alarmNotification.soundName = UILocalNotificationDefaultSoundName; 
   // alarmNotification.soundName = @"glass.aiff"; // "glass.aiff" is a file in my application bundle
   [[UIApplication sharedApplication] presentLocalNotificationNow:alarmNotification];
}

I also show UIAlertViewwhich will be initialized and displayed from AppDelegateupon receipt of the notification:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
   UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"alert"  message:@"Local notification was received" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
   [alertView show];
}

A local notification is received and a warning is displayed, in the notification center I also see that the notification has been started, only the sound does not work ...

, , , , push- , , ...

, ? - - , ?

, , - , ( , , , ).

, , , ...

the notification center proves that all my local notifications are firedthe alert proves that my app delegate receives the local notification

+4
3

, . , .

, , .

Apple push notification:

, , , . : didReceiveLocalNotification: , . UILocalNotification , userInfo.

, AudioServicesPlaySystemSound(), .

+9

UINotification , , , , , , , .

.

+4

*.caf. , . *.mp3 *.wav, .

, .

*.caf?

1)

2) :

cd// /Desktop/FolderName

"Enter"

3)

afconvert -f caff -d LEI16 @22050 -c 1 BlaBla.mp3 BlaBlaNew.caf

"Enter"

+1

Source: https://habr.com/ru/post/1539693/


All Articles