ocwendel ocwendel -4 years ago 300
Swift Question

Login freezes using FBSDK for iOS

I have an iOS app written in swift that uses Facebook login (FBSDK 4.11.0). The app is in production, and FB-login works perfectly.

However, while working on a new update I realised that I'm no longer able to sign in or register using FB. The login process stops after having authorized the application in the popup webview. It loads a blank page and stands still.

below code is the exact same code that is currently running perfectly on the version in the app store. I thought this might have something to do with the fact that the app is currently in dev, but after creating a beta and downloading it through testflight I still get the same problem.

Here is my code.

func fbLoginInitiate() {
if hasSeenPermissionPopup(LoginType.Facebook){
Globals.mixpanel.track("Initiated FB login")
FBSDKLoginManager().logInWithReadPermissions(["public_profile", "email", "user_birthday"], fromViewController: self, handler: {(result:FBSDKLoginManagerLoginResult!, error:NSError!) -> Void in
if (error != nil) {
// Process error
} else if result.isCancelled {
// User Cancellation
} else {
if result.grantedPermissions.contains("email") && result.grantedPermissions.contains("public_profile") && result.grantedPermissions.contains("user_birthday") {
//Do work
} else {
Globals.mixpanel.track("Facebook login failed")
SweetAlert().showAlert("Ooops!", subTitle: "Noe gikk galt. Ta kontakt med Mojob dersom feilen vedvarer", style: AlertStyle.Warning)

Error is nil in the callback, and result only shows if I cancel the request. I've not done any changes to info.plist or any other settings that has to do with FB in the app.

If anyone has experienced anything similar, I would really appreciate hearing about how you solved the problem.

First part of the login works as expected

enter image description here

Second part freezes

enter image description here

Answer Source

Is your AppDelegate correctly configured for the facebook SDK? If not you should add the following functions to it:

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
           return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)

application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

Se this issue for more information:


In the issue they refer to this website where I found the correct setup:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download