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
self.removeFbData()
} else if result.isCancelled {
// User Cancellation
self.removeFbData()
} else {
//Success
if result.grantedPermissions.contains("email") && result.grantedPermissions.contains("public_profile") && result.grantedPermissions.contains("user_birthday") {
//Do work
self.fetchFacebookProfile()
} 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
Second part freezes
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:
https://github.com/facebook/react-native-fbsdk/issues/72
In the issue they refer to this website where I found the correct setup:
https://developers.facebook.com/docs/ios/getting-started#delegate