2012-04-01 2 views
0

저는 iOS 개발의 초보자이고 로컬 알림을 지원하는 정적 라이브러리를 작성하려고합니다. didReiniveLocalNotification, didFinishLaunchingWithOptions없이 알림에서 이벤트를 수신 할 수 있습니까? 내가 시도 :did not didReceiveLocalNotification, didFinishLaunchingWithOptions

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handle:) name:UIApplicationDidFinishLaunchingNotification object:nil]; 

내가 (아직 아이폰 OS 6.0)을 didReceiveLocalNotification 방법에 대한 글로벌 옵저버를 포함하는 것이 가능하다고 생각하지 않습니다

답변

0

도와주세요.

그러나 didFinishLaunchingWithOptions 메소드에 대한 전역 옵저버를 만들 수 있습니다.

NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 
[center addObserver:self selector:@selector(notifyApplicationDidFinishLaunching:) name:UIApplicationDidFinishLaunchingNotification object:nil]; 

-(void)notifyApplicationDidFinishLaunching:(NSNotification*)notification { 
    NSLog(@"Application did finish launching: %@", notification); 
    UILocalNotification *localNotification = [notification.userInfo objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; 
} 

이 관찰자를 사용하면 응용 프로그램이 실행 중이 아닌 (닫혀 있거나 종료 된) 로컬/푸시 알림을 포착 할 수 있습니다.

응용 프로그램이 백그라운드에있는 경우이 메서드는 호출되지 않습니다.

관련 문제