2012-07-31 92 views
2

我将闹钟时间设置为1小时。当应用程序处于运行模式时,闹钟工作正常,但当它处于后台时,闹钟无法正常工作。如何在后台运行闹钟?如何在iPhone SDK中的后台运行闹钟?

+0

您应该使用本地通知。 – Ishu 2012-07-31 04:47:35

+0

@Ishu @Ishu我已经使用本地通知,但通知闹钟铃声只响30秒我想扩大闹钟ton – 2012-07-31 04:50:38

回答

2

您需要使用本地通知。这很简单。有关更多信息,请参阅此文档(推送通知来自远程来源,因此您可以忽略它们)。

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008194-CH1-SW1

+0

我已经使用本地通知,但只有30秒的闹钟响,我想延长振铃时间1分 – 2012-07-31 04:31:05

+0

thanx的建议,但我想要不同的方式来敲响闹钟,我不想使用本地通知:) – 2012-07-31 04:38:51

+0

我想再次成为30。 – 2012-07-31 05:19:11

1

该代码只显示与警报localNotification和健全的背景。 因此,一些代码更改和警报应用程序中使用。

- (IBAction)Alert:(id)sender{ 

    NSDateFormatter *format = [[NSDateFormatter alloc] init]; 
    [format setDateFormat:@"yyyy-MM-dd"]; 
    //NSDate *date = [NSDate date]; 


    UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 
    localNotif.fireDate =[NSDate dateWithTimeIntervalSinceNow:15]; 
    localNotif.timeZone = [NSTimeZone localTimeZone]; 
    localNotif.alertBody = @"Emergency"; 

    localNotif.alertAction = @"View"; 
    localNotif.soundName = @"police.mp3"; 
    localNotif.applicationIconBadgeNumber = 1; 
    localNotif.repeatInterval = NSYearCalendarUnit; 


    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 
    [localNotif release]; 



} 
+0

thanx我已经用这种方式,但我想不同的连续运行警报本地通知铃声只响30秒 – 2012-07-31 05:04:26