2011-11-01 5 views
5

알림 센터에있는 모든 것을 구성하면 앱에서 알림을 표시 할 수 있으므로 내 앱의 로컬 알림은 실행되지 않습니다.iOS5에서 로컬 알림이 작동하지 않습니다.

같은 문제가 발생합니까?

자세한 내용은 :

  1. 엑스 코드 4.1과 아이폰 OS 4.3 SDK로 컴파일 며칠 전 같은 소스 코드에서 컴파일 같은 응용 프로그램은, 모든 것이 잘 작동합니다.

  2. 또한 이전 버전의 Xcode 및 iOS SDK로 컴파일 된 앱은 업그레이드 후 iOS5에서 작동 할 수 있습니다.

그러나 같은 코드로 컴파일되었지만 XCode 4.2 및 iOS5 SDK는 컴파일되지 않는 응용 프로그램이 작동하지 않습니다.

의견이 있으십니까? iOS5에 특별한 작업이 있습니까?

샘플 코드는 같은 수 있습니다 :

UIApplication *app = [UIApplication sharedApplication]; 
NSArray *oldNotifications = [app scheduledLocalNotifications]; 

// Clear out the old notification before scheduling a new one. 
if (0 < [oldNotifications count]) { 

    [app cancelAllLocalNotifications]; 
} 

// Create a new notification 
UILocalNotification *alarm = [[UILocalNotification alloc] init]; 
if (alarm) { 

    alarm.fireDate = theDate; 
    alarm.timeZone = [NSTimeZone defaultTimeZone]; 
    alarm.repeatInterval = NSDayCalendarUnit; //repeat every day 
    alarm.alertBody = [NSString stringWithFormat:@"alert"];  
    [app scheduleLocalNotification:alarm]; 
    [alarm release]; 
} 

감사에서 iOS 5에서 마이클

답변

11

이, 알림 알림 센터에 의해 관리됩니다. 응용 프로그램을 알림 센터에 프로그래밍 방식으로 등록하거나 프로그래밍 방식으로 프로그래밍 방식으로 Settings > Notifications으로 이동하여 알림 센터 사용, 경고 스타일 선택 등의 적절한 설정을 선택해야합니다.

당신은 applicationDidFinishLaunching:에 넣어, 알림 센터 (프로그램) 사용하여 응용 프로그램을 등록하는 코드의 다음 조각을 사용할 수 있습니다

// Although Register For Remote Notifications is not required for Local Notifications, 
// but in iOS 5's Notifications, we have to register otherwise the system doesn't register/recognize 
// the notifications posted from the application. Note that this behavior is not documented 
// as of Oct 2011, and it's possible that it's a bug and will be handled in the future releases. 

[[UIApplication sharedApplication] registerForRemoteNotificationTypes: 
UIRemoteNotificationTypeAlert | 
UIRemoteNotificationTypeSound]; 

HTH를.

+0

APN 서비스를 사용하려면 앱 ID 및 SSL 인증서도 구성해야합니까? – user370773

+0

답변을 주셔서 감사합니다. 또한 UILocalNotificationDefaultSoundName은 iOS 5.0에서 몇 가지 문제가 있습니다. –

관련 문제