I am implementing the notification this way:
-(void)scheduleLocalNotificationWithDate:(NSDate *)AlarmDate{
UILocalNotification *Notification = [[UILocalNotification alloc]init];
Notification.fireDate = AlarmDate;
Notification.alertBody = @"Time to wake up!";
Notification.soundName = @"sound.caf";
[[UIApplication sharedApplication] scheduleLocalNotification:Notification];
}
So, when the notification fires there’s no sound. What may be the problem?
*file name is correct
*sound duration: 32sec
*I am using IOS simulator
*sound is in “supporting files”, “physically” also in the project folder
*Tried to set the absolute path but that didn’t help either.
UPD: not local, Push notification.(i mean even if you close the app it will work)
I’m confused, you say you’re sending a push notification but your code shows a local notification.
For a push notification, your app has to specify that it wants sounds when it gets its push notification token:
If your app initially registered for notifications without requesting audio notifications, you may have to delete your app and reinstall before iOS notices that your app has changed its mind.
Also, make sure that Sounds is turned on in Settings > Notifications > YOUR_APP.
In addition, Apple’s Local and Push Notification Programming Guide says that custom sounds may be at most 30 seconds in length, otherwise the default notification is played. This applies to both push and local notifications.