Facebook login not working iOS 10

Good Day All,


I am having an issue with an app and logging in with Facebook.


My app uses this method:


FBSDKLoginManager logInWithReadPermissions:<#(NSArray *)#> fromViewController:<#(UIViewController *)#> handler:<#^(FBSDKLoginManagerLoginResult *result, NSError *error)handler#>


The web view comes up, shows the app as already authorized, I tap OK the webview reloads but then nothing happens, it stays on a blank page, and the delegate isn't called to process the login.


Does anybody have a workaround for this?


I am already on the latest Facebook iOS SDK, 4.13.1, there are no updates, and I can't find anything online.


Is anyone else having this issue?

I've been able to successfully login with Facebook by tapping the little Open in Safari icon at the bottom right, and when asked "Are you sure you want to submit this form again?", tapping submit, and then get the confirmation to "Open this page in "App Name"?". When I tap "Open" I get pushed back to my app and it continues as usual.


So perhaps something with URL scheme's not working properly from webviews within an app and iOS 10?

Same for me

callback for this method is never called

fbLoginManager.logIn(withReadPermissions: ["public_profile", "email", "user_friends"], from: self) { (result, error) -> Void in


the following message appears in logs:
-canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

Oh my! I've been having the same issue. I thought I installed the SDK wrong but everything I changed, followed a-z, nothing changed. There is definitely an issue.

I have same issue http://stackoverflow.com/questions/38689631/how-to-use-facebook-ios-sdk-on-ios-10

Some problem in IOS 10 so FBSDK cant use `SecItemUpdate` to update keychain

Was anyone able to resolve this issue?

WIth iOS 10 beta 8 and the latest Facebook SDK it appears this issue has been resolved.

Sounds good. Thanks!

Running Xcode 8 GM with latest FBSDKCoreKit and FBSDKLoginKit and am still seeing this issue. Am really stumped. Tried toggling the Keychain Sharing option as noted in the StackOverflow thread, but no luck.


Should be noted that we are seeing this exact same issue with Google Signin as well.

Curious to know if anyone has been able resolve this issue recently.

This has been resolved for me, perhaps in my tweaking and altering the URL schemes to try make it work I fixed it too.


Here is my current LSApplicationQueriesSchemes key in my Info.plist


<key>LSApplicationQueriesSchemes</key>
<array>
        <string>fbapi</string>
        <string>fbapi20130214</string>
        <string>fbapi20130410</string>
        <string>fbapi20130702</string>
        <string>fbapi20131010</string>
        <string>fbapi20131219</string>
        <string>fbapi20140410</string>
        <string>fbapi20140116</string>
        <string>fbapi20150313</string>
        <string>fbapi20150629</string>
        <string>fbapi20160328</string>
        <string>fbauth</string>
        <string>fbauth2</string>
        <string>fb-messenger-api20140430</string>
        <string>fb-messenger-platform-20150128</string>
        <string>fb-messenger-platform-20150218</string>
        <string>fb-messenger-platform-20150305</string>
        <string>fbapi</string>
        <string>fb-messenger-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
</array>


I pretty much have every facebook query in there from before. I beleive this was the only change I had made since it stopped working with the original beta. Then now with the GM making sure the FBSDK is on the latest version, and with these key values in there, it is working fine again for me.

We Solved it!! Our issue was some third party plugins trying to auto integrate into our app delegate. For us, it was CleverTap (the `autoIntegrate()` function).


Be safe out there.

I got the same issue.


The fix was changing the using viewcontroller:


FBSDKLoginManager logInWithReadPermissions:<#(NSArray *)#> fromViewController:viewcontrollerA

We was presenting the view seperated (without presenting the attached viewcontrollerA) so we have to use the current active viewcontrollerB.

In my situation the completion handler is never called

FBSDKLoginManager logInWithReadPermissions:<#(NSArray *)#> fromViewController:<#(UIViewController *)#> handler:<#^(FBSDKLoginManagerLoginResult *result, NSError *error)handler#>


so in debuging, i put the breakpoint in "FBSDKLoginManager.m" at "logInWithBehavior:(FBSDKLoginBehavior)loginBehavior" and findout that weakSelf getting nil and not be able to call "logInWithBehavior: serverConfiguration: serverConfigurationLoadError:"


- (void)logInWithBehavior:(FBSDKLoginBehavior)loginBehavior
{
  __weak __typeof__(self) weakSelf = self;
  [FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:^(FBSDKServerConfiguration *serverConfiguration, NSError *loadError) {
    [weakSelf logInWithBehavior:loginBehavior serverConfiguration:serverConfiguration serverConfigurationLoadError:loadError];
  }];
}


Solution:

In my case, I change FBSDKLoginManager variable as property rather than using as function variable. Make sure, FBSDKLoginManager varibale must reamin alive until the completion handler call

@dev.hoha

This solved the issue for me. Thank you very much. BTW: I found the weakSelf being nil myself and googled for "facebook weakSelf logInWithBehavior:" to find this page.

The facebook login documentation is wrong at this time for XCode 8. However the issue is not related to a specific iOS version. It ocures on both iOS 9 and iOS 10 when built with XCode 8.

@cybergen


Thanks for sharing the fixed. But for second time you login came from the logout. Still a Blank page any suggestion how to fix it. Thanks in advance.

In my case, the problem was Google Analytics. By default it seems it's adding its own view controller on top of the app's view controller.

Setting "FirebaseAppDelegateProxyEnabled" to "NO" in the <Your app>-Info.plist solved the problem.

Not sure if this is related, I hit a similar issue where the facebook login page would show and after authentication I was stranded at a blnak white page. Clicking done, would result in user cancelled.


What got things working was adding the following to my plist:



<key>NSAppTransportSecurity</key>

<dict>

<key>NSExceptionDomains</key>

<dict>

<key>akamaihd.net</key>

<dict>

<key>NSIncludesSubdomains</key>

<true/>

<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>

<false/>

</dict>

<key>facebook.com</key>

<dict>

<key>NSIncludesSubdomains</key>

<true/>

<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>

<false/>

</dict>

<key>fbcdn.net</key>

<dict>

<key>NSIncludesSubdomains</key>

<true/>

<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>

<false/>

</dict>

</dict>

</dict>

<key>LSApplicationQueriesSchemes</key>

<array>

<string>fbapi</string>

<string>fb-messenger-api</string>

<string>fbauth2</string>

<string>fbshareextension</string>

</array>


I also need to change my AppDelegate as follows:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

// Override point for customization after application launch.

return SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)

}


func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool

{

return SDKApplicationDelegate.shared.application(app, open: url, options: options)

}


After those changes everything started working. This on Swift 3.0, Facebook Swift SDK on XCode8 works with IOS10.

Are you able to solve this issue ?
I am facing the same problem for ios 10.0.1 and I am not able to find a solution for it.
Can you help me in that ?

In my case i'd split out the App Delegate for the iPhone into a different file, and forgotten to return YES in canOpenURL for the facebook app prefix.

Perhaps i'm the dumbest in this thread.

I've managed to resolve it. Our problem was the following code


if (url.scheme?.hasPrefix("fb\(FBSDKSettings.appID())"))! && url.host == "authorize" {
            return FBSDKApplicationDelegate.sharedInstance().application(application,
                                                                         open: url,
                                                                         sourceApplication: sourceApplication,
                                                                         annotation: annotation)
        }

Now with the new Swift 3 FBSDKSettings.appID() is returned as String! and printing it was Optional(...). So, changing that code to be

if (url.scheme?.hasPrefix("fb") ?? false) && url.host == "authorize" {
            return FBSDKApplicationDelegate.sharedInstance().application(application,
                                                                         open: url,
                                                                         sourceApplication: sourceApplication,
                                                                         annotation: annotation)
        }


Essentially, make sure the following function is called:

FBSDKApplicationDelegate.sharedInstance().application(application,
                                                                         open: url,
                                                                         sourceApplication: sourceApplication,
                                                                         annotation: annotation)

Error OSStatus -10814 occures when canOpenURL: can't find any application, that can open this URL (Facebook trying to find their app by calling CanOpenURL: with argument fbauth2:/) Printing happens inside of function, so you can't do anything with that. But if you will run your application on device with installed Facebook app you will not see this error. (thanks to Roman Ermolov from stackoverflow)

Personally I managed to login on simulator with iOS 8 instead (downloaded additional simulator).

Thanks dev.hoha!Using the following worked for me.


@property (strong, nonatomic) FBSDKLoginManager *login;

I had the same issue. I use my custom Login button. My solution is:


func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any])

-> Bool {

FBSDKApplicationDelegate.sharedInstance().application(application,

open: url,

sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String,

annotation: options [UIApplicationOpenURLOptionsKey.annotation]

return true

}


I am returning true because I am implementing few social medias.

For anyone still having issues with this and sdk 4.19.0 adding this to my appdelegate fixed the issue


    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance()
          .application(application,
                       open: url as URL!,
                       sourceApplication: sourceApplication,
                       annotation: annotation)
    }

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance()
          .application(app,
                       open: url as URL!,
                       sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String,
                       annotation: options[UIApplicationOpenURLOptionsKey.annotation])
    }

Here is solution that worked for me: http://stackoverflow.com/a/32300235/1728397

Facebook login not working iOS 10
 
 
Q