【发布时间】:2016-02-22 05:08:43
【问题描述】:
当推送通知到达时,当应用程序处于终止状态时,我需要通过点击推送通知启动应用程序时从appdelegate导航到特定的视图控制器?
//处理推送通知的辅助方法
- (void)handleNotification:(NSDictionary *)userInfo {
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
NSString * token = [defaults objectForKey:@"token"];
UINavigationController *navigationController = (UINavigationController *) self.window.rootViewController;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
if (token!=NULL) {
// Show the dashboard
[navigationController pushViewController:[storyboard instantiateViewControllerWithIdentifier:@"listviewcontroller"] animated:NO];
} else {
// Login
[navigationController pushViewController:[storyboard instantiateViewControllerWithIdentifier:@"viewcontroller"] animated:NO];
}
}
这是正确的吗? 还是我需要进行任何更改?
【问题讨论】:
-
我认为您需要在
ApplicationDidfinishLaunching中编写代码才能在您的应用被杀死时获取通知详细信息。 -
@SibaPrasadHota:我已经从应用程序调用了这个方法并完成了启动
标签: ios objective-c xcode