I have successfully scheduled local notifications in my app using the code below:
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil) {
UILocalNotification *notification = [[cls alloc] init];
notification.fireDate = self.alarmNotificationDate;
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.alertBody = @"Alarm is due";
notification.alertAction = @"Show Alarm";
notification.soundName = @"alarm.mp3";
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
[notification release];
Where self.alarmNotificationDate is a NSDate assign in another method.
All works fine in the simulator, but when I test on my trusted old iPhone 3G running iOS4 I get the notification, but only with the default sound.
I have tried with different sound files but no success.
Any clue why it could be like this and how to correct it?
Thanks
UILocalNotification does not support mp3. It only supports the formats and containers mentioned on the reference page.
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html
Because custom alert sounds are played by the iOS system-sound facility, they must be in one of the following audio data formats:
Linear PCM MA4 (IMA/ADPCM) µLaw aLaw
You can package the audio data in an aiff, wav, or caf file.
There could be a couple of reasons:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With