Search code examples
swiftfirebase-authenticationfacebook-loginfacebook-ios-sdksfsafariviewcontroller

Facebook Login doesn't doesn't dismiss Login Dialog after login


Using LoginManager from the Facebook iOS SDK to login like so:

let loginManager = LoginManager()
loginManager.logIn([.publicProfile, .email], viewController: self) { (loginResult) in

The Login Dialog opens facebook.com through Safari, which has a button for me to

Log In with the Facebook App

When I click "Continue" in the Facebook app I am returned back to my app, however the Login Dialog is not dismissed even though loginResult returns .success.

This is what is displayed after returning to my app after being successfully logged in: enter image description here

The only option is for me to click 'Cancel'. It seems like the Login Dialog is SFAuthenticationViewController, which currently contains 0 results on a Google search.

It seems problems other people have had in the past was that in their AppDelegate they were not calling the appropriate authorization flow processing in application:openURL:options: but that is successfully being called like so:

@available(iOS 9.0, *)
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
    print("application open url\n\(url)\noptions \(options)")

    if url.absoluteString.hasPrefix("fb") {
       print("Finishing Facebook log in flow")
       return SDKApplicationDelegate.shared.application(application, open: url, options: options)
    } else {
        print("Finishing Google sign in flow")
        return GIDSignIn.sharedInstance().handle(url, sourceApplication:options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: [:])
    }
}

The only thing I can think of is some incompatibility issues since I am using Swift 4 on iOS 11 Developer beta, and the fact that there are no results online for SFAuthenticationViewController which is seemingly being used.

I am unsure why the dialog isn't automatically being dismissed.


Update:

I created a brand new, blank app with only a single button and the FacebookCore and FacebookLogin dependencies and the issue still persists.

Steps followed:

  1. https://developers.facebook.com/docs/facebook-login/ios
  2. https://developers.facebook.com/docs/swift/getting-started
  3. https://developers.facebook.com/docs/swift/login

Solution

  • Update:

    Now working in SDK 0.3.0: https://github.com/facebook/facebook-sdk-swift/releases


    Update, official response from Facebook:

    Hi Gareth,

    Thanks for flagging this! iOS 11 is still in beta, and we don't currently support it.

    Best regards, Günay


    This is a bug on devices running iOS 11. Works fine on devices running iOS 10.

    Bug report filed here: https://github.com/facebook/facebook-sdk-swift/issues/172