尝试在收到通知时从应用代理启动特定的tabView对象,但应用程序在启动时崩溃。
以下是代码:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *viewController;
CustomTabViewController * tabBar = [[CustomTabViewController alloc] init];
NSDictionary *notificationPayload = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
NSString *type = [notificationPayload objectForKey:@"type"];
if([type isEqualToString:@"friend"]){
tabBar.selectedViewController = [tabBar.viewControllers objectAtIndex:2];
self.window.rootViewController = tabBar;
[self.window makeKeyAndVisible];
}
if([type isEqualToString:@"message"]){
tabBar.selectedViewController = [tabBar.viewControllers objectAtIndex:0];
self.window.rootViewController = tabBar;
[self.window makeKeyAndVisible];
}
有什么想法吗?