1
votes

I have been stuck on the same problem for a while, and I hope someone can help.

I created an alarm clock app, which uses UILocalNotification to play an alarm sound at the selected time.

My app was working fine on the simulator, but when I started testing it on an iPhone, the notification sound stopped ringing.

I have the sound in .caf, about 20 seconds long, correct capitalization and everything, so I really can't figure out why it doesn't ring. I use the same sound file elsewhere in the app, and it works fine, so I do know the file is loaded properly. The notification shows up properly, just without the sound. And yes, I made sure the volume is turned up on my iPhone.

Does anyone have any idea why this is happening? Below is my code.

Thank you in advance! -Ema

UILocalNotification* alarm = [[ULocalNotification alloc] init];
alarm.fireDate = pickedDate;
alarm.timeZone = [NSTimeZone defaultTimeZone];
alarm.hasAction = YES;
alarm.alertAction = @"SNOOZE";
alarm.repeatInterval = 0;
alarm.soundName =  @"Alarm11.caf";
alarm.alertBody = @"Alarm";    
[app scheduleLocalNotification:alarm];
2
I read, that your sound vol is turned up, but just to be sure: the mute button is in off-state? - marcus
Yes, once the app starts up all the sounds work as intended. It's just the UILocalNotification sound. - emama
The default sound is working fine, I assume? (UILocalNotificationDefaultSoundName) - marcus
Yes, it is. The only problem is that I'm making an alarm clock so the default "ping" noise is too short for my purpose. :( - emama
Can you doublecheck the internal format of the file as described in Preparing Custom Alert Sounds - marcus

2 Answers

0
votes

I had the same problem and found a solution in a similar question on Stackoverflow (but I can't find it again to provide the link) - The solution to my problem was to open the System Preferences for my mac and open the Sounds option. In the Sounds screen, uncheck and then re-check the 'Play user interface sound effects' to re-set and your sound should then play ok.

0
votes

I had a similar issue. Make sure the target membership is checked in the file inspector tab. Also, remove the app from your phone, do a clean build and then, restart your phone and see if it works.