ios - Perform segue from AppDelegate -


i need perform segue appdelegate when user has left app in background more 3 minutes. code:

func applicationwillenterforeground(_ application: uiapplication) {     // called part of transition background active state; here can undo many of changes made on entering background.     let preferences = userdefaults.standard     let time_in = preferences.object(forkey: "time_background") as! date     let timenow = date().addingtimeinterval(-3*60) date     if time_in <= timenow {         print("timeout")         //transition login     }     print(preferences.object(forkey: "session_time") ?? "test") } 

so @ //transition login want segue bring user login page.

but don't understand how segue appdelegate.

func showloginscreen(){     let loginvc = uistoryboard.getmainstoryboard().instantiateviewcontroller(withidentifier: "loginviewcontrolleridentifier") as! loginviewcontroller      uiapplication.shared.delegate!.window!!.rootviewcontroller = loginvc      }  extension uistoryboard{     //returns storyboard default bundle if bundle paased nil.     public class func getmainstoryboard() -> uistoryboard{         return uistoryboard(name: "main", bundle: nil)     } } 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -