当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - I'm trying to keep my user logged in even after the app is killed by double tapping the homebutton and swiping up on the application. I'm using parse

问题描述:

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

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: