2011-01-05 5 views
2

이 절대 멍청한 놈 질문이지만, 나는 문서 또는 다른 스택 질문에서이 일을 알아낼 수없는 경우 미안 해요 -UILocalNotification 일정

내가있는 NSDate를 설정하는 방법 GMT에서 오전 10 시까 지 개체를 찾으십니까? 내가 묻는 이유는 이것입니다. 매일 오전 10시에 그리니치 표준시에 현지 알림을 설정하려고합니다.

나는 다음은 바른 길에 생각 :

NSDateComponents *comps = [[NSDateComponents alloc]init]; 
[comps setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; 

[comps setYear:2011]; 
[comps setMonth:1]; 
[comps setWeek:1]; 
[comps setDay:1]; 
[comps setHour:10]; 
[comps setMinute:52]; 
[comps setSecond:0]; 

NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar]; 

NSDate *date = [gregorian dateFromComponents:comps]; 
[comps release]; 

UILocalNotification *notif = [[UILocalNotification alloc]init]; 

notif.fireDate = date; 
notif.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; 
notif.alertBody = @"New Challenges are available in Halo: Reach.\n\n Give them a look over with Halo Reach Challenges!"; 
notif.alertAction = @"Show Me"; 
notif.applicationIconBadgeNumber = 5; 
notif.repeatInterval = NSDayCalendarUnit; 

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

불행하게도,이 발생하지 않습니다. 어떤 도움을 크게 주시면 감사하겠습니다 :)

답변

1

응용 프로그램이 실행되는 한 알림은 귀하의 앱으로 직접 전송됩니다. (appDelegate에서) 핸들러를 설정하고 메시지를 직접 표시해야합니다. 앱이 실행되고 있지 않으면 알림이 표시되어야합니다.

+0

UILocalNotification 문서에 링크 된 프로토콜 참조가 있다고 가정합니다. 내가해야 할 일은 의도 한 메시지가있는 UIAlertView를 보여주는 것입니다. –

+0

예. 그게 다야. – Axel

+0

좋아요, 그리고 내가 과거에 날짜를 설정했다면, 반복과 함께 ... 순간적으로 발생하지만 재연 간격은 여전히 ​​유효합니다, 맞습니까? 아니면 오늘 날짜를 얻어 분할하고 하루를 추가해야합니까? –