尝试打开不是启动的viewController。
在AppDelegate文件的didFinishLaunching .....方法中我把这段代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions{
if([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeAlert) categories:nil];
[application registerUserNotificationSettings:settings];
}else{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeNone)];
}
if (launchOptions != nil) {
// NSLog(@"Launched from push notification");
UINavigationController *navController = (UINavigationController *)self.window.rootViewController;
NewNotification *notificationViewController = [[NewNotification alloc] init];
[navController.visibleViewController.navigationController pushViewController:notificationViewController animated:YES];
}
return YES;
}
当我发送推送通知并点击它时,它会打开应用程序,然后崩溃......该怎么办?