滑动推送通知时显示ViewController

时间:2015-01-09 22:01:07

标签: ios objective-c push-notification apple-push-notifications

尝试打开不是启动的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;

}

当我发送推送通知并点击它时,它会打开应用程序,然后崩溃......该怎么办?

0 个答案:

没有答案
相关问题