Facebook login error - canOpenURL: failed URL: "fbauth2: ///" - error: "(null)"

When I click on the login button using the Facebook button, it opens the Safari browser and closes immediately. Reported error on console.

Application Delegation Method:

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { print("###### URL : ") print(url) print("###### App : ") print(app) print(options["UIApplicationOpenURLOptionsSourceApplicationKey"]) return FBSDKApplicationDelegate.sharedInstance().application(app, openURL: url, sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as! String, annotation: nil) } 
 2015-09-18 18: 37: 51.410 [21036: 5050465] -canOpenURL: failed for URL: "fbauth2: ///" - error: "(null)"

 2015-09-18 18: 37: 51.417 [21036: 5050465] -canOpenURL: failed for URL: "fbauth2: ///" - error: "(null)"

  ###### URL: 

   fb4554284912963222: // authorize /? error_code = 100 & error_message = Invalid + Scope% 3A + public & state =% 7B% 22challenge% 22% 3A% 222ZmK6R5F05d% 252F060TkCqj8SjPLjc% 253D% 22% 2C% -702% -261_70_aut_2% -261_aut_2% -261_aut_2% -261_aut_id AE1B-E1C68435DB83% 22% 2C% 22com.facebook.sdk_client_state% 22% 3Atrue% 2C% 223_method% 22% 3A% 22sfvc_auth% 22% 7D & e2e =% 7B% 22init% 22% 3A145973.000512302% 7A

    ###### App: 

   
     Optional (com.apple.SafariViewService)
     nil

    ###### err:

    Optional (Error Domain = com.facebook.sdk.core Code = 8 "(null)" UserInfo = {com.facebook.sdk: FBSDKGraphRequestErrorGraphErrorCode = 100, com.facebook.sdk: FBSDKErrorDeveloperMessageKey = Invalid Scope: public, com.facebook. sdk: FBSDKGraphRequestErrorCategoryKey = 0})

IDE: xcode 7
Language: Swift2
Facebook SDK: 4.6.0
Analysis: 1.8.4

I also checked .plist has all the keys that are required. Also checked is the link identifier for typo errors. Everyone looks good. Facebook is active.

Any help?

+51
ios facebook swift facebook-graph-api
Sep 19 '15 at 2:02
source share
9 answers

I have the same warning, but there is an answer on Facebook Docs.

This is an Xcode warning indicating canOpenURL: call returns false. As long as you configured the LSApplicationQueriesSchemes entry in your plist as described above, you can ignore this warning

https://developers.facebook.com/docs/ios/ios9

+37
Nov 12 '15 at 12:04
source share

"-canOpenURL: failed for URL" warning is a red herring, but simply means that the FB application is not installed on the device / simulator in which you are working.

It looks like you are requesting an invalid area (aka permission) for "Public". Can you include your code, which includes the permissions that you request? public_profile is probably what you want (and what the SDK is by default if none are provided).

More importantly, DO NOT add fbauth2 to your CFBundleURLSchemes, as this will break your logins. As Himansha pointed out, these entries should be entered in the LSApplicationQueriesSchemes section in our plist.

+27
Mar 29 '16 at 16:35
source share

If you recompile iOS SDK 9.0, add the following to your application layer if you are using SDK version v4.6.0 or higher:

  <key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fb-messenger-api</string> <string>fbauth2</string> <string>fbshareextension</string> </array> 

To get ready for the Facebook integration supported by iOS 9, go through Facebook Integraion for iOS 9.

To check the facebook SDK version, use the following line of code:

  print("SDK version \(FBSDKSettings .sdkVersion())") 
+4
Nov 20 '15 at 17:16
source share

I missed the import of FBSDKCoreKit . He later started working on a simulator, but not on an iPhone device.

The following FAQ was also spotted on Facebook. Why do I see console messages, for example

'canOpenURL: failed URL: "fb ...: //'

or? This is an Xcode warning indicating that a call to canOpenURL: returns false. If you configured the LSApplicationQueriesSchemes entry in plist as described above, you can ignore this warning

For iPhone devices, refer to: Analysis API - Facebook login does not work on iPhone

+2
Sep 22 '15 at 3:24
source share

You have an extra "/" in your fbauth2: /// url.

Then you can see "error_message = Invalid + Scope" in the URL, probably you should check the permissions of your application: https://developers.facebook.com/docs/facebook-login/permissions/v2.4

0
Sep 19 '15 at 4:51 on
source share

The problem is related to application transport security introduced in iOS 9.

There are two solutions that are related to fixing the info.plist file.

Here's the manual http://discoverpioneer.com/blog/2015/09/18/updating-facebook-integration-for-ios-9/

0
Sep 19 '15 at 16:40
source share

You need to add this method if your application runs on iOS9 or higher.

 - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options { return [[FBSDKApplicationDelegate sharedInstance] application:app openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]]; 

}

If you need a Swift version:

 @available(iOS 9.0, *) func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { return SDKApplicationDelegate.shared.application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation] as Any) } 
0
Apr 20 '17 at 9:16
source share

This is an Xcode warning indicating that canOpenURL: call returned false. As long as you have configured the LSApplicationQueriesSchemes entry in your plist as described above, you can ignore this warning.

Go to this link. Choose your application and configure info.plist

import And add this code to your AppDelegate

 import FBSDKCoreKit . import FBSDKLoginKit func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) } func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { return FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options) } 
0
Sep 13 '17 at 18:01
source share

I understood my problem. It was just the syntax in the loginButtonClicked function. The error message led me to the wrong path. Here is the working code.

 @objc func loginButtonClicked() { self.login = FBSDKLoginManager() self.login.logIn(withReadPermissions: ["public_profile"], from: self, handler: {(result, error) -> Void in if error != nil { print("Process error") } else if (result?.isCancelled)! { print("Cancelled") } else { print("Logged in") DispatchQueue.main.async(execute: { let viewController:UIViewController = self.storyboard?.instantiateViewController(withIdentifier: "UITabBarController") as! UITabBarController self.present(viewController, animated: true, completion: nil) }) } }) } 
0
Nov 12 '17 at 13:52
source share



All Articles