2012-07-31 29 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