How can I play an audible alarm for more than 30 seconds, for example, an application for an alarm clock?

I am trying to create an alarm clock similar to Alarm Clock Pro and the Nightstand app, which is currently in the app store. Each of these applications can play an alarm sound for more than 30 seconds when the response time sounds (usually the next morning).

I 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 can play an alarm in a loop after 7 hours?

+5
source share
3 answers

- , . , , , , .

:

30 , , (, ).

, , , didReceiveLocalNotification .

+5

, fireDate

UILocalNotification *localNotif = [[[UILocalNotification alloc] init]autorelease];
localNotif.fireDate = scheduleDate;
NSLog(@"fireDate is %@",localNotif.fireDate);
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = @"WAKE UP...!!!";
localNotif.alertAction = @"View";
localNotif.soundName = @"Default.wav";


[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];

, , , , "Default.wav" 30 , Alarm Clock pro = 30 .

, appdelegate > 30 .....

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification 
{ 
}
+1

, , :

To simulate an audible alarm for more than 30 seconds, simply add a few local values ​​one by one at a distance of 30 seconds.

-2
source

All Articles