푸시 알림을 사용할 수있는 3 개의보기 컨트롤러와 앱이있는 스토리 보드가있는 앱을 개발하고 있습니다. 푸시 알림을받을 때 알림 알림을 탭하면 내 스토리 보드에서 두 번째보기 컨트롤러를 열어야 내 코드를 표시 할 수 있습니다. 또한 두 번째보기 컨트롤러로에있는 버튼이 그 내가로드 할 컨트롤러 인 실제로 내 첫 번째보기 컨트롤러apple pushnotification을받을 때 storyboard에서 viewcontroller를 엽니 다.
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotification" object:nil userInfo:userInfo];
}
다음 스토리 보드로드합니다. 여기 첫 번째보기 컨트롤러의 코드가 있습니다.
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushNotificationReceived) name:@"pushNotification" object:nil];
}
-(void)pushNotificationReceived{
NSString * storyboardName = @"DealerMainStoryboard";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"DealerBuyRequests"];
[self presentViewController:vc animated:YES completion:nil];
}
알림을받을 때이 코드로 알림을받을 때 앱이 다운됩니다.
그리고 어디에 문제가 있습니까? – iCode
푸시 알림이 표시되고 알림을 탭하면 앱이이 코드와 충돌합니다. – user2966615
오류 로그 란 무엇입니까? – iCode