프로그래밍/iOS
[ios] 시리나 홈버튼을 들어갈 때 Notification 얻기
삶의안식처
2015. 4. 9. 14:31
1. 시리로 들어가거나 홈버튼을 눌렀을 때
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(siriWillApear:) name:UIApplicationWillResignActiveNotification object:nil];
2. 시리에서 돌아오거나 메인화면에서 앱으로 다시 돌아올 때
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(siriWillDisAppear:) name:UIApplicationDidBecomeActiveNotification object:nil];
3. 위에서 selector로 지정해준 함수 작성하기
#pragma mark - siri notification
-(void) siriWillApear : (NSNotification*) notification
{
NSLog(@"siriWillApear");
//할일 작성
}
-(void) siriWillDisAppear : (NSNotification*) notification
{
NSLog(@"siriWillDisAppear");
//할일 작성
}