我正在我的项目中使用SWRevealViewController,并希望在应用程序接收到通知时打开特定的控制器。我尝试了很多解决方案,但没有一个有效。如何从我的AppDelegate中显示一个特定的ViewController?
(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
UIApplicationState appState = UIApplicationStateActive;
if ([application respondsToSelector:@selector(applicationState)]) {
appState = application.applicationState;
}
application.applicationIconBadgeNumber = 0;
if (appState != UIApplicationStateActive) {
SWRevealViewController *navigationController = (SWRevealViewController *)self.window.rootViewController;
UINavigationController *nav = (UINavigationController *)navigationController;
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
PushNotificationsVC *controller = (PushNotificationsVC*)[mainStoryboard instantiateViewControllerWithIdentifier: @"PushNotificationsVC"];
[nav pushViewController:controller animated:YES];
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Notification"
message:[NSString stringWithFormat:@"%@",[[userInfo objectForKey:@"aps"] valueForKey:@"alert"]]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
[self.window.rootViewController presentViewController:MyCustomViewController animated:NO completion:nil]
?你能展示一下你在-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo;
方法中有什么吗? - Ali Abbas