I'm relatively new to programming and am coding an app that involves users registering in facebook. Whenever I press the facebook login it kicks me out to safari and kicks me back when I login. I understand the app store requires you to login without switching applications for usability, is there anyway to prevent this? When I exit the app, it seems my token is not stored and I have to log back in. I have looked through stack overflow and all the answers seemed to be in objective c and over 2 years old. I have also updated to ios 9, so this may be part of the issue. Here's my view controller code below where I create the button and add it to the vc.
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if (error == nil) {
println("Login complete")
} else {
println(error.localizedDescription)
}
}
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
println("User logged out...")
}
override func viewDidLoad() {
super.viewDidLoad()
if (FBSDKAccessToken.currentAccessToken() == nil) {
println("Not logged in...")
} else {
println("Logged in...")
}
var loginButton = FBSDKLoginButton()
loginButton.readPermissions = ["public_profile", "email", "user_friends"]
loginButton.center = self.view.center
loginButton.delegate = self
self.view.addSubview(loginButton)
}