Facebook-ios-sdk: iOS 13 cannot login

Created on 2 Oct 2019  Â·  36Comments  Â·  Source: facebook/facebook-ios-sdk

Checklist

Environment

  • Xcode Version: 11.0.0
  • Swift Version: 5.1.0
  • Installation Platform & Version: Cocoapods 1.8.1
  • Facebook SDK version: 5.8.0

Goals

I want my users to login to my app through Facebook login.

Expected Results

I expect to log in.

Actual Results

Gets stuck in facebook login flow.

Video

Steps to Reproduce

  • Install the Facebook App
  • Log in on the Facebook App
  • Log out from facebook in Safari.

Code Samples & Details

let manager = FacebookLoginManager()
manager.logIn(permissions: ["email"], from: UIWindow.current?.topViewController) { result, error in
    // Callback not even called when pressing Cancel
}

Most helpful comment

With the latest SDK, this does work fine if you are at NOT using SceneDelegate.

If you are using sceneDelegate the the following AppDelegate method is not called and therefore the login cannot be handled.

func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    let handled = ApplicationDelegate.shared.application(
        application,
        open: url,
        sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
        annotation: options[UIApplication.OpenURLOptionsKey.annotation])
    return handled
}

This is because, this method is (understandably) deferred to the following method in the SceneDelegate:

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    ...
}

The solution which I can confirm as working for iOS 13 applications implementing a SceneDelegate is:

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    guard let url = URLContexts.first?.url else {
        return
    }
    let _ = ApplicationDelegate.shared.application(
        UIApplication.shared,
        open: url,
        sourceApplication: nil,
        annotation: [UIApplication.OpenURLOptionsKey.annotation])        
}

All 36 comments

i faced the same problem, nearly 1 month and facebook don't fix it at all

@arbitur Same problem with you.
But if you are already login facebook in your Safari, you can login successful instead of using Facebook app.
I'm also waiting the fix

I have same problem. When i login without logged, i can't touch to "Cancel" or "Open" button. I think ios 13 break popup function, same as my delegate in UIAlertView.

@tienrocker try restarting the device. I had the same problem and iPhone restarting fixed the problem... It is really strange, but it helped.

It seems that the error is in func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool with iOS 13 options no longer contain the key .sourceApplication which the Facebook SDK requires.

@tienrocker try restarting the device. I had the same problem and iPhone restarting fixed the problem... It is really strange, but it helped.

it's work, so weird, thanks

"applications are no longer notified of the source application unless they are from the same application group." https://forums.developer.apple.com/thread/119118

We just encountered this issue and started investigation. Will this be resolved any time soon?

我也是一直返回Cancelled

Still not working in 5.8.0

Use
application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool
instead of
application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any?) -> Bool
in AppDelegate in
application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool
worked for me

@gumenuk39 See my comments above about that. Log out from facebook in Safari and then try logging in on your app and you should experience the bug.

application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any?) -> Bool has been deprecated since iOS 9 so Im assuming no one is using that method anymore.

I've logged out from FB in safari and using app to log in. All works correctly on latest version of sdk.
I used application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any?) -> Bool of fb Application Delegate and got sourceApplication from options using guard.
So, I removed that code and changed it to application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool of fb ApplicationDelegate and it works for me

@gumenuk39 Is your device running iOS 13?

@arbitur yes. I've tested on iOS 12.4, iOS 13.0, iOS 13.1

@gumenuk39 And do you also have the Facebook App installed and is logged in on it?

@arbitur yes. I'm using FB app to login.

@gumenuk39 Is the iOS 13 device a physical device or simulator? Do you receive the .sourceApplication key in options the open url method?

@arbitur iOS 13 device. No, I don't receive the .sourceApplication and I don't need it anymore.
I'm just using ApplicationDelegate.shared.application(app, open: url, options: options)

@gumenuk39 Wow it works now. The Getting started guide is wrong then and needs an update.

Getting started guide is updated. Thanks all!

Still broken

we cannot release this in this state and there is no workaround that will prevent our users from having a horrible experience.

Issue when logging with facebook on iOS13 any body has same issue here? After asking user to continue the app freezes. Check video link.
Login issue video
I'm using SDK 5.10.0
iOS 13.1.3

I’m not sure what Facebook did but ours was working and now it doesn’t

Douglas W. Palme
President / CEO
Palme Acres Technology Group, LTD


From: Kegham Karsian notifications@github.com
Sent: Wednesday, November 13, 2019 9:15:48 AM
To: facebook/facebook-ios-sdk facebook-ios-sdk@noreply.github.com
Cc: Douglas Palme dpalme@palmeacres.com; Comment comment@noreply.github.com
Subject: Re: [facebook/facebook-ios-sdk] iOS 13 cannot login (#1067)

Issue when logging with facebook on iOS13 any body has same issue here? After asking user to continue the app freezes. Check video link.
Login issue videohttps://youtu.be/oT4i8Es0cdI
I'm using SDK 5.10.0

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/facebook/facebook-ios-sdk/issues/1067?email_source=notifications&email_token=AG4QTPEQGD7UQHCTGH2P7NDQTQK2JA5CNFSM4I4TBGEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED6PAZI#issuecomment-553447525, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG4QTPBJBTI37QCIRJBFWELQTQK2JANCNFSM4I4TBGEA.

@arbitur Same problem with you.
But if you are already login facebook in your Safari, you can login successful instead of using Facebook app.
I'm also waiting the fix

do you found any solution found ?

We pulled the plug on Facebook login, too much trouble and Facebook is a poor excuse as a solution.

Douglas W. Palme
President / CEO
Palme Acres Technology Group, LTD


From: nitinumaretiya123 notifications@github.com
Sent: Tuesday, November 26, 2019 10:07:02 AM
To: facebook/facebook-ios-sdk facebook-ios-sdk@noreply.github.com
Cc: Douglas Palme dpalme@palmeacres.com; Comment comment@noreply.github.com
Subject: Re: [facebook/facebook-ios-sdk] iOS 13 cannot login (#1067)

@arbiturhttps://github.com/arbitur Same problem with you.
But if you are already login facebook in your Safari, you can login successful instead of using Facebook app.
I'm also waiting the fix

do you found any solution found ?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/facebook/facebook-ios-sdk/issues/1067?email_source=notifications&email_token=AG4QTPH7PGM7HXDTYOJHU5LQVVCSNA5CNFSM4I4TBGEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFGRICQ#issuecomment-558699530, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG4QTPDIQV4IEQL5DPYM66LQVVCSNANCNFSM4I4TBGEA.

With the latest SDK, this does work fine if you are at NOT using SceneDelegate.

If you are using sceneDelegate the the following AppDelegate method is not called and therefore the login cannot be handled.

func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    let handled = ApplicationDelegate.shared.application(
        application,
        open: url,
        sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
        annotation: options[UIApplication.OpenURLOptionsKey.annotation])
    return handled
}

This is because, this method is (understandably) deferred to the following method in the SceneDelegate:

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    ...
}

The solution which I can confirm as working for iOS 13 applications implementing a SceneDelegate is:

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    guard let url = URLContexts.first?.url else {
        return
    }
    let _ = ApplicationDelegate.shared.application(
        UIApplication.shared,
        open: url,
        sourceApplication: nil,
        annotation: [UIApplication.OpenURLOptionsKey.annotation])        
}

5.11.1 and application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool doesn't work either.

5.11.1 and application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool doesn't work either.

@shkbahmad - if you are using SceneDelegate, this will not work - if this is the case for you, see my comment above yours.

@shkbahmad You mention that you are getting the compilation error:

Use of unresolved identifier 'ApplicationDelegate'

Since ApplicationDelegate is a part of the FBSDKCoreKit, you might not have imported it - simply add the following line above the SceneDelegate Class declaration:

import FBSDKCoreKit

You should be able to implement the following in the SceneDelegate without any issue:

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    guard let url = URLContexts.first?.url else {
        return
    }
    let _ = ApplicationDelegate.shared.application(
        UIApplication.shared,
        open: url,
        sourceApplication: nil,
        annotation: [UIApplication.OpenURLOptionsKey.annotation])        
}

Let me know if you still have any issue - happy to help.

Hi, I resolved it by following these steps.

  1. Delete Pods folder and Podfile.lock
  2. Update your pods in podfile like this.
    Replace
    pod 'FacebookCore'
    pod 'FacebookLogin'
    pod 'FacebookShare'
    with
    pod 'FBSDKCoreKit/Swift'
    pod 'FBSDKLoginKit/Swift'
    pod 'FBSDKShareKit/Swift'
  3. Pod install

You can see more discussion about this issue from https://github.com/facebookarchive/facebook-swift-sdk/issues/482#issuecomment-509987192

Still seeing this issue still on 5.15.0. None of the suggested fixes have worked.

I have seen the facebook app return to the source application once (the sdk does not successfully login the user), but since then the login flow gets stuck on a blank screen on the facebook app without redirecting.

I've implemented the openURL methods in the app delegate and scene delegate according to the documentation, and have tried the suggested changes which haven't had an effect.

Testing on device with iOS 13.2. I have restarted the device, deleted the facebook app, logged in with different test user accounts, but the results are the same.

Logging in through the modal browser works fine, but using the app redirect flow does not.

Any ideas?

I have same issue. I created new project with last template (xCode 11.3, iOS 13.2) and add last facebook SDK with cocapods for test. Login with Facebook App not working (

I have seen the facebook app return to the source application once (the sdk does not successfully login the user),

The native app redirect flow has been deprecated for some time now. This is not expected to work.
See: https://github.com/facebook/facebook-ios-sdk/blob/master/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.h#L124

If there is a new issue, please reopen with steps to reproduce. Locking this thread.

Was this page helpful?
0 / 5 - 0 ratings