Here is some code.
UIApplication *app = [UIApplication sharedApplication];
NSArray *oldNotifications = [app scheduledLocalNotifications];
if ([oldNotifications count] > 0) [app cancelAllLocalNotifications];
NSString *filePath = [DOCUMENTS stringByAppendingPathComponent:@"personal2.wav"];
//NSLog(@"%@",filePath);
//filePath = [[NSBundle mainBundle] pathForResource:@"wolf" ofType:@"wav"];
UILocalNotification *localNotif = [[UILocalNotification alloc]init];
localNotif.fireDate = alarmPicker.date ;
localNotif.timeZone = [NSTimeZone localTimeZone];
localNotif.alertBody = @"Alarm";
localNotif.alertAction = @"View";
localNotif.soundName = filePath;
localNotif.applicationIconBadgeNumber = 1;
//localNotif.repeatInterval = NSYearCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
So it shows just alert but it is not playing wav. When i click View it starts the app and in didReceiveLocalNotification method i play this song again and it sounds good.
Can somebody help me with issue. Thanks
P.S. I read that duration of wav should be les than 30 sec and it is 22 seconds so it should play
P.S.2 Is it a way to repeat of playing the song when the localnotifications fires up. THANKS
Check if you have
App plays audioinRequired background modesin your app’s target properties.