2017-11-08 1 views
1

사용자가 푸시 알림을받을 때 특정 응용 프로그램 페이지를 시작할 때 문제가 있습니다.ios 푸시 알림 응용 프로그램을 시작하는 방법

이 작업을 수행 할 수 있습니까?

예, 그렇다면 저를 도울 수 있습니까?

+2

가능한 [iOS 푸시 알림을 수신 할 때보기 컨트롤러 열기] (https://stackoverflow.com/questions/20757362/open-a-view-controller-when-a-ios-push-notification- 수신 됨) – Luzo

+0

응용 프로그램 페이지가 실행 됨으로써 응용 프로그램을 여는 것을 의미합니까? 정교한 ... –

답변

0

원격 알림을 받고이 알림에 UIViewController을 등록하면 알림을 보내고 알림을 받으면 특정 UIViewController을 열 수 있습니다.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ 

    [[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotification" object:nil userInfo:userInfo]; 

} 

이 알림을 수신하기위한 FirstViewController.m 등록기에서. 당신이 특정의 ViewController

을 열 수있는 방법 내부

-(void)viewDidLoad{ 

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushNotificationReceived) name:@"pushNotification" object:nil]; 

} 

-(void)pushNotificationReceived{ 

[self presentViewController:self.secondViewController animated:YES completion:nil]; 
} 

마지막으로 등록을 취소

-(void)dealloc{ 
[[NSNotificationCenter defaultCenter] removeObserver:self]; 

} 

당신이 어떤 문제에 직면 알려줘의 dealloc 방법으로 통지에서 현재의 ViewController를 .

+0

확인 중입니다. 빠른 도움에 감사드립니다. –