Reputation: 5635
I am developing alarm application and I know that it is not recommended to use UILocalNotification. Using Local Notification I cannot make sound loop for example. Is there any alternatives to UILocalNotification? And which method is fired when notification appears?
Upvotes: 0
Views: 311
Reputation: 61
UILocalNotification * localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = targetDateTime;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.userInfo = @"Its Morning Time";
NSString * soundName = [[NSUserDefaults standardUserDefaults]valueForKey:@"ColorName"];
localNotification.soundName = [NSString stringWithFormat:@"%@.wav",soundName];
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
[[UIApplication sharedApplication]scheduleLocalNotification:localNotification];
By using above code we can fire UILocalNotification as alarm & can play your own sound file as a alarm sound.
For playing different different files as a alarm sound you can give user an interface like in UIPickerView in which all Notification sounds names are dispalyed. The selected file become as a alarm sound for the user.
One more thing you can do is by calling a function after one day interval you can choose different sound file and can play as a alarm sound file.
Hope this info help you.
Upvotes: 1