원격 알림을 받고 알림 유형에 따라 탐색 컨트롤러의보기 컨트롤러를 변경합니다.앱이 실행되지 않을 때 원격 알림을 처리 할 때 크래시가 발생합니다.
앱이 포 그라운드에 있거나 앱이 백그라운드에 있지만 완전히 닫히지 않은 경우 (멀티 태스킹 표시 줄에서) 모두 정상적으로 작동합니다.
하지만 앱이 닫히고 원격 알림을 받으면 앱이 열리 자마자 충돌이 발생합니다. ViewController를 설치하는 방식에 문제가 있습니까?
여기에 몇 가지 코드가 있습니다.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {
// Push required screens into navigation controller
UILocalNotification *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
//Accept push notification when app is not open
if (remoteNotif) {
[self handleRemoteNotification:application userInfo:remoteNotif.userInfo];
return YES;
}
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
-(void) handleRemoteNotification:(UIApplication *)application userInfo:(NSDictionary *)userInfo {
application.applicationIconBadgeNumber = 0;
NSMutableArray *viewControllers = [NSMutableArray array];
[viewControllers addObject:driverWaitViewController];
[viewControllers addObject:newJobsViewController];
[navigationController setViewControllers:viewControllers];
}
회신 해 주셔서 감사합니다. 문제는 뭔가 다른. 내가 어떻게 해결했는지 보아라. – Prasanna
그래, 그게 이상하다고 생각했지만, 나는 따라 잡지 못했다. 죄송합니다. – vakio