Я использую SWRevealViewController в своем проекте, и я хочу открыть конкретный контроллер, когда приложение получает уведомление. Я пробовал так много решений, но ничего не работает.
Как я могу показать определенный ViewController из моего AppDelegate?
(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];
}
}