I'm trying to build an alarm clock similar to the Alarm Clock Pro and the Nightstand application that are currently in the app store. Each of these applications is able to play an alarm clock sound for more than 30 seconds when the alarm time is hit (usually the next morning).
I've tried two approaches already with no luck:
Approach 1:
[self performSelector:@selector(playAlarm) withObject:nil afterDelay:myDouble];
Approach 2:
UILocalNotification *notif = [[cls alloc] init];
notif.fireDate =[datePicker date];//firedate;
notif.timeZone = [NSTimeZone systemTimeZone];
notif.alertBody = @"Time to wake up!";
NSString *SoundFileName=nil;
if([[[NSUserDefaults standardUserDefaults] objectForKey:@"ActualSoundFile"] isKindOfClass:[NSString class]])
SoundFileName=[[[NSString alloc]initWithString:[[NSUserDefaults standardUserDefaults]objectForKey:@"ActualSoundFile"]]autorelease];
else
SoundFileName=[[[NSString alloc] initWithString:@""] autorelease];
if([SoundFileName length]>1)
notif.soundName = [SoundFileName stringByAppendingString:@".wav"];
else
notif.soundName = UILocalNotificationDefaultSoundName;
notif.alertAction=@"Snooze";
notif.repeatCalendar=[NSCalendar currentCalendar];
notif.repeatInterval =NSDayCalendarUnit;
NSDictionary *userDict = [NSDictionary dictionaryWithObject:@"Alarm" forKey:kRemindMeNotificationDataKey];
notif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];
Does anyone know how they're able to play the alarm on a loop after 7 hours?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…