When Push notification arrives, when app is in kill state , I need to navigate to specific view controller from appdelegate when the app is launched by tapping push notification?
//helper method to handle push notification
- (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];
}
}
Is this Correct? or do I need to make any changes?