이벤트 날짜가 가까워지면 알림 센터를 통해 사용자에게 알리미를 보내는 앱을 작성하고 있습니다. 그러나 날짜 선택 도구에서 날짜를 설정하고 앱을 종료하면 알림이 표시되지 않습니다. 프로비저닝 프로파일에서 이미 푸시 알림을 활성화했습니다. 내 objectForKey 영역 때문일 수 있습니다. 나는 ImportantDatesViewController_iPhone1 및 ImportantDatesViewController_iPad1이라는 2 개의 닙 (하나는 iPhone 용, 하나는 iPad 용)을 가지고 있습니다. objectForKey 영역을 "ImportantDatesViewController"대신 nib 이름으로 변경해야합니까? 그리고 .h 및 .m 파일 이름은 단순히 ImportantDatesViewController입니다. 미안하지만, 나는 아직도 이것에 대해 아주 새롭고 내가가는 것처럼 배우고있다. 여기 알림 센터를 다루는 내 프로젝트의 모든 코드입니다, 이것은 내가 내보기 컨트롤러에 넣어 것입니다 :iPhone iOS : 로컬 알림이 나타나지 않습니다.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"mm'/'dd'/'yyyy"];
NSDate *eventDate = [[NSUserDefaults standardUserDefaults] objectForKey:@"ImportantDatesViewController.selectedDate"];
localNotif.fireDate = [eventDate dateByAddingTimeInterval:-60*60*60];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = @"Event coming in three days!";
localNotif.alertAction = nil;
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
return YES;
}
나는 또한 앱 내 didFinishLaunchingWithOptions 방법이 코드를 추가아래쪽의 대표자, 그리고 트릭을 할 것이라고 생각 :
[[UIApplication sharedApplication]registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
도움을 주셔서 감사합니다.
그냥 보조 노트, 나는 내가 이전을 삭제하고 올바른 형식이 게시, 이전에 이것에 대해 게시하지만, 잘못을 기록했다. 의 – John
가능한 중복 (http://stackoverflow.com/questions/8958898/iphone-local-notifications-wont-appear) – Abizern