Facebook SDK delegate methods not firing

I have a very simple setup:

import Foundation
import UIKit
import FacebookLogin
import FBSDKLoginKit

class Authenticate: UIViewController,FBSDKLoginButtonDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        let loginButton = FBSDKLoginButton()
        loginButton.delegate = self
        loginButton.center = view.center
        view.addSubview(loginButton)
    }

    func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
        print("DID LOG OUT!!!")
    }


    func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
        print("Login Delegate callback")
        if error != nil {
            print(error)
            return
        }
        print("successfully logged into facebook")
    }
}

Everything appears generally to work fine with the login process (I get the FB prompt, login, am brought back to the app, etc.)

However, the delegates methods NEVER fire. I never see “DID LOG OUT” or “Login Delegate Callback” or “successfully logged into facebook”.

What am I missing?

Thanks in advance for help/suggestions.

Miner Asked on June 29, 2017 in General Stack.
Add Comment


  • LATEST ANSWERS

  • 1 Answer(s)

    This answer helped me determine the root cause issue. The 2 keys are SSO and Safari. Facebook poorly documents the Facebook Login process. I had to turn off SSO. This is on the Facebook Developer site, where your app is registered, under Settings. But more importantly is I had to change the behavior of the FBLoginManager to use UIWebView and not Safari. I did this with the following snippet:

    let deletepermission = FBSDKGraphRequest(graphPath: "me/permissions/", parameters: nil, HTTPMethod: "DELETE")
    deletepermission
    .startWithCompletionHandler({(connection,result,error)-> Void in
    println
    ("the delete permission is \(result)")

    })


    If you use the default behaviors it will manage logouts through the Facebook App or the browser Safari, and not directly from the App.
    The FBSDKLoginBehaviorWeb is to use iOS UIWebView in a popup. This works perfectly, and credentials are required each time after a logout.
    Default Answered on June 30, 2017.
    Add Comment

    Write your answer

    By posting your answer, you agree to the privacy policy and terms of service.