我收到通知但我的应用程序没有运行,我通过通知打开应用程序,所以我不能跳过 ViewController。那是我的代码。
AppDelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive)
{
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
if([[NSUserDefaults standardUserDefaults] valueForKey:@"username"] && [[NSUserDefaults standardUserDefaults] valueForKey:@"password"] && [[NSUserDefaults standardUserDefaults] valueForKey:@"companyid"])
{
HomeViewController *hm= [storyBoard instantiateViewControllerWithIdentifier:@"HomeView"];
self.window.rootViewController = hm;
}
else
{
NSLog(@"LoginView");
}
}
else
{
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
if([[NSUserDefaults standardUserDefaults] valueForKey:@"username"] && [[NSUserDefaults standardUserDefaults] valueForKey:@"password"] && [[NSUserDefaults standardUserDefaults] valueForKey:@"companyid"])
{
HomeViewController *hm= [storyBoard instantiateViewControllerWithIdentifier:@"HomeView"];
self.window.rootViewController = hm;
}
else
{
NSLog(@"LoginView");
}
}
}