2012-05-14 2 views
0

저는 iphone을 처음 사용합니다. 아래 코드로 작업 중입니다. 로컬 알림은 10 초 이내에 실행되지 않으며 반복 간격도 작동하지 않으며 모든 알림을 표시하지 않습니다. 1 분 firedate 통화 second.After과 같은 방법으로 반복 간격은 매 15의 반복 간격을 설정할 수있는 모든 일 minute.how 작동 sec.If 사람이로컬 알림을 사용자 정의 시간 간격으로 표시

- (void)applicationDidEnterBackground:(UIApplication *)application { 
    NSLog(@"1"); 

    NSTimeInterval interval = 10; 
    NSDate *alertTime = [NSDate dateWithTimeIntervalSinceNow:interval]; 
    UIApplication* app = [UIApplication sharedApplication]; 
    UILocalNotification* notifyAlarm = [[UILocalNotification alloc] init]; 
    if (notifyAlarm){ 
     notifyAlarm.fireDate = alertTime; 

     notifyAlarm.alertAction = @"Message"; 
     notifyAlarm.alertBody = @"Alert"; 
     notifyAlarm.hasAction = YES; 
     notifyAlarm.timeZone = [NSTimeZone defaultTimeZone]; 

     notifyAlarm.repeatInterval = NSSecondCalendarUnit; 
     // timer = [[NSTimer alloc]initWithFireDate:alertTime interval:interval target:self selector:@selector(sendRequest) userInfo:nil repeats:YES]; 

     [app scheduleLocalNotification:notifyAlarm]; 

     } 
+0

명확한 아이디어는 무엇입니까? – Dev

답변

0

당신이 필요로 ...이 저를 도와주세요 알고 appDelegate에이를 구현하여 앱이 실행되는 동안 알림이 작동하도록합니다.

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { 
    //do something 
} 
관련 문제