FBSDKAccessToken nil

When I use the Facebook SDK to handle the Backendless login I receive nil in the FBSDKAccessToken when I try to login. My callback is shown below.


 func application(_ app: UIApplication, open url: URL, options: [String : AnyObject] = [:]) -> Bool {
 
  let source = options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String
 
 let facebook = FBSDKApplicationDelegate.sharedInstance()!
 let handled:Bool = facebook.application(app, open: url, sourceApplication: source, annotation: nil) 
 
 if (handled) {
 
 let token = FBSDKAccessToken.current()
 
 let mappings = ["email":"email"]
 
 var fault:Fault?
 let user = backendless.userService.login(withFacebookSDK: token, fieldsMapping: mappings, error: &fault)
 
 if (fault == nil) {
 print("\(user)")
 } else {
 print("Server reported an error: \(fault!)")
 }
 
 }
 
 return true
 
 }


Please try this:

    func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
        
        let result = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
        if result {
            
            let token = FBSDKAccessToken.currentAccessToken()
            let fieldsMapping = [
                "id" : "facebookId",
                "name" : "name",
                "birthday": "birthday",
                "first_name": "first_name",
                "last_name" : "last_name",
                "gender": "gender",
                "email": "email"
            ]
            
            backendless.userService.loginWithFacebookSDK(
                token,
                fieldsMapping: fieldsMapping,
                response: { (user: BackendlessUser!) -> Void in
                    print("user: \(user)")
               },
                error: { (fault: Fault!) -> Void in
                    print("Server reported an error: \(fault)")
            })
        }
        
        return result
    }

Sorry, I forgot to mention that I use Swift 3 and Xcode Beta 2.

Why you couldn’t use the above function in Swift 3?

You could, but the method is deprecated. It’s list with strikethrough in beta 2.

However, still returns nil for access token.

So, you get nil with a call

let token = FBSDKAccessToken.currentAccessToken()

How is this associated with Backendless SDK?