2

I'm trying to set an object of myViewController called myVC to the window's rootViewController on the AppDelegate like that:

-(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler
{
    self.myVC=(myViewController*)self.window.rootViewController;
}

It's all working when the app is running but on the background it doesn't working at all.

Anybody knows how can I make it work on the background as well?

Thank you!

FS.O
  • 403
  • 6
  • 24

1 Answers1

0

Try this

EDIT:

AppDelegate.m

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"STORYBOARD_NAME" bundle:nil];
ViewController *ViewController = [storyboard instantiateViewControllerWithIdentifier:@"YOUR_IDENTIFIER"];[self.window makeKeyAndVisible];     
[self.window.rootViewController presentViewController:ViewController animated:YES completion:NULL];
return YES;
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
NSLog(@"applicationDidEnterBackground");
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:ADD_YOURCONTROLLER];

[self presentViewController:navController animated:YES completion:nil];
}

Hope this helps.

Kamlesh Shingarakhiya
  • 2,757
  • 2
  • 16
  • 34