25 Replies
      Latest reply on Mar 5, 2017 12:01 PM by ivanfrommoscow
      Dvelopin Level 1 Level 1 (0 points)

        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?

        • Re: Facebook login not working iOS 10
          Dvelopin Level 1 Level 1 (0 points)

          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?

          • Re: Facebook login not working iOS 10
            mkitaigo Level 1 Level 1 (0 points)

            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.)"

              • Re: Facebook login not working iOS 10
                Rafay Level 1 Level 1 (0 points)

                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 ?

                • Re: Facebook login not working iOS 10
                  Ka_dze Level 1 Level 1 (0 points)

                  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).

                • Re: Facebook login not working iOS 10
                  HalesEnchanted Level 1 Level 1 (0 points)

                  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.

                  • Re: Facebook login not working iOS 10
                    trquoccuong Level 1 Level 1 (0 points)

                    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

                    • Re: Facebook login not working iOS 10
                      vishaal Level 1 Level 1 (0 points)

                      Was anyone able to resolve this issue?

                      • Re: Facebook login not working iOS 10
                        vishaal Level 1 Level 1 (0 points)

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

                        • Re: Facebook login not working iOS 10
                          Dvelopin Level 1 Level 1 (0 points)

                          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.

                          • Re: Facebook login not working iOS 10
                            roycuriosity Level 1 Level 1 (0 points)

                            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.

                            • Re: Facebook login not working iOS 10
                              ploenne Level 1 Level 1 (0 points)

                              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.

                              • Re: Facebook login not working iOS 10
                                dev.hoha Level 1 Level 1 (0 points)

                                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

                                  • Re: Facebook login not working iOS 10
                                    cybergen Level 1 Level 1 (0 points)

                                    @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.

                                      • Re: Facebook login not working iOS 10
                                        4ks Level 1 Level 1 (0 points)

                                        @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.

                                          • Re: Facebook login not working iOS 10
                                            mscherzer Level 1 Level 1 (0 points)

                                            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.

                                        • Re: Facebook login not working iOS 10
                                          bluemachine Level 1 Level 1 (0 points)

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

                                           

                                          @property (strong, nonatomic) FBSDKLoginManager *login;

                                        • Re: Facebook login not working iOS 10
                                          da1 Level 1 Level 1 (0 points)

                                          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.

                                          • Re: Facebook login not working iOS 10
                                            xaphod Level 1 Level 1 (0 points)

                                            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.

                                            • Re: Facebook login not working iOS 10
                                              mohamed-afifi-zalando Level 1 Level 1 (0 points)

                                              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)
                                              
                                              • Re: Facebook login not working iOS 10
                                                eugene7777 Level 1 Level 1 (0 points)

                                                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.

                                                • Re: Facebook login not working iOS 10
                                                  c.blahut Level 1 Level 1 (0 points)

                                                  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])
                                                      }
                                                  
                                                  
                                                  • Re: Facebook login not working iOS 10
                                                    ivanfrommoscow Level 1 Level 1 (0 points)

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