问题描述:

I'm trying to keep a user logged in my app even after the app is terminated by double clicking the home button and swiping up on the app. This is what i have but it still brings me to the login page.

I'm not sure what to do with the session or why its not working.

I put this in my appdelegate didFinishLaunchingwithOptions

 Parse.setApplicationId("ParseID",

clientKey: "ParseClient")

if ((PFUser.currentUser()!.sessionToken) != nil)//check if user was logged in with token

{

//go to Home page if there is user

let storyboard = UIStoryboard(name: "Main", bundle: nil)

let vc = storyboard.instantiateViewControllerWithIdentifier("Home") as! UIViewController

self.window?.rootViewController?.presentViewController(vc, animated: true, completion: nil)

}else{

// else take to login page

let storyboard = UIStoryboard(name: "Main", bundle: nil)

let vc = storyboard.instantiateViewControllerWithIdentifier("Login") as! UIViewController

self.window?.rootViewController?.presentViewController(vc, animated: true, completion: nil)

}

return true

}

相关阅读:
Top