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?

Replies

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