Swift 5 - Facebook Login: LoginManager() callback doesn't call with Facebook App installed

Viewed 3377

I've updated Facebook SDK to the latest version with cocoapods:

  • Using FBSDKCoreKit (5.8.0)
  • Using FBSDKLoginKit (5.8.0)
  • Using FacebookCore (0.9.0)
  • Using FacebookLogin (0.9.0)

When Facebook app is installed, LoginManager() callback is not called. When the app is not installed and the browser is used, it works.

let loginManager = LoginManager()
loginManager.logIn(permissions: [.publicProfile, .email], viewController: self, completion: { loginResult in
    switch loginResult {
    case .failed(let error):
        print("\(error)")
    case .cancelled:
        print("cancelled")
    case .success(let grantedPermissions, let declinedPermissions, let accessToken):
        print("\(grantedPermissions) \(declinedPermissions)")
    }
})

Any idea?

2 Answers

Updating to the new SDK solved:

pod 'FBSDKCoreKit/Swift'
pod 'FBSDKLoginKit/Swift'

I had this same issue. For me it was missing code from the AppDelegate (we don't use a SceneDelegate). The sign in would work unless the FB app was installed. The former used a web view type UI but the latter switched to the FB app, then when returned to our app it hang. Looking at the FB account I could see the sign in had worked successfully.

Check the FB docs: https://developers.facebook.com/docs/facebook-login/ios/

(5. Connect Your App Delegate and Scene Delegate)

Related