How to restart the application when multitasking resumes

Thus, my application relies on an Internet connection, and each time the application opens from the main screen, it checks the use of Reachability, and then allows the user to continue or inform them to connect. My problem however is that when the application resumes from multitasking, it skips the initial view controller and goes straight to where they were. Is there any quick way so that I can update or restart the application when it resumes from multitasking?

thanks

EDIT When using this code:

let storyboard = UIStoryboard(name: "MainStoryboard", bundle: nil) self.window.rootViewController = MainStoryboard.instantiateInitialViewController() 

I get the expected announcement error. enter image description here

+1
source share
3 answers

You can install the root view controller and it will restart your main VC. Assuming you are using a storyboard:

(self refers to your AppDelegate)

Swift:

 let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil) self.window.rootViewController = storyboard.instantiateInitialViewController() 

Objective-C:

 self.window.rootViewController = [[UIStoryboard storyboardWithName:@"MyStoryboardName" bundle:nil] instantiateInitialViewController]; 
+6
source

I just added the following to plist: "Application does not work in the background" and set it to "YES"

It would seem to work.

+2
source

You can use the navigation controller:

  let vc = self.storyboard!.instantiateViewController(withIdentifier: "FirstPageViewController") as! FirstPageViewController self.navigationController?.pushViewController(vc, animated: true) 
0
source

All Articles