IT TIP

페이스 북 로그인 문제-canOpenURL : URL에 대한 실패 : "fbauth2 : ///"-오류 : "(null)"

itqueen 2020. 12. 8. 20:32
반응형

페이스 북 로그인 문제-canOpenURL : URL에 대한 실패 : "fbauth2 : ///"-오류 : "(null)"


Facebook 버튼으로 로그인을 클릭하면 사파리 브라우저가 열리고 즉시 닫힙니다. 콘솔에서 오류를 발견했습니다.

앱 델리게이트 방법 :

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 : URL 실패 : "fbauth2 : ///"-오류 : "(null)"

2015-09-18 18 : 37 : 51.417 [21036 : 5050465] -canOpenURL : URL 실패 : "fbauth2 : ///"-오류 : "(null)"

###### URL : 

fb4554284912963222 : // authorize /? error_code = 100 & error_message = Invalid + Scope % 3A + public & state = % 7B % 22challenge % 22 % 3A % 222ZmK6R5F05d % 252F060TkCqj8SjPLjc % 253D % 22 % 2C % 220_61B223C79F2C8-61B223C79F2C8-auth_logger_id % 22 % 3A % 223C79F2C8 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 % 7D # _ = _

###### 앱 : 


선택 사항 (com.apple.SafariViewService)

###### 오류 :

선택 사항 (오류 도메인 = com.facebook.sdk.core Code = 8 "(null)"UserInfo = {com.facebook.sdk : FBSDKGraphRequestErrorGraphErrorCode = 100, com.facebook.sdk : FBSDKErrorDeveloperMessageKey = 잘못된 범위 : public, com.facebook. sdk : FBSDKGraphRequestErrorCategoryKey = 0})

IDE : xcode 7
언어 : Swift2
Facebook SDK : 4.6.0
구문 분석 : 1.8.4

또한 .plist에 필요한 모든 키가 있는지 확인했습니다. 또한 오타 실수에 대한 번들 식별자를 확인했습니다. 모두 좋아 보인다. Facebook이 활성화되었습니다.

도움이 필요하세요?


같은 경고가 있지만 Facebook Docs에는 답변이 있습니다.

canOpenURL : 호출이 false를 반환했음을 나타내는 Xcode 경고입니다. 위에서 설명한대로 plist에서 LSApplicationQueriesSchemes 항목을 구성한 경우이 경고를 무시할 수 있습니다.

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


"-canOpenURL : URL 실패"경고는 빨간색 청어이며 단순히 실행중인 장치 / 시뮬레이터에 FB 앱이 설치되어 있지 않음을 의미합니다.

'공개'의 유효하지 않은 범위 (권한이라고도 함)를 요청하신 것 같습니다. 요청하는 권한이 포함 된 코드를 포함 할 수 있습니까? public_profile은 아마도 당신이 원하는 것입니다 (그리고 아무것도 제공되지 않으면 SDK가 기본값으로 설정하는 것).

더 중요한 것은 로그인 흐름을 중단 할 수 있으므로 CFBundleURLSchemes에 fbauth2를 추가 하지 마십시오 . Himanshu가 지적했듯이 이러한 항목은 plist의 LSApplicationQueriesSchemes 아래에 입력해야합니다.


iOS SDK 9.0으로 다시 컴파일하는 경우 Facebook SDK v4.6.0 이상의 버전을 사용하는 경우 애플리케이션의 plist에 다음을 추가합니다.

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

iOS 9에 지원되는 Facebook 통합을 준비하려면 iOS 9 지침에 대한 Facebook 통합을 참조하십시오.

facebook SDK의 버전을 확인하려면 아래 코드 줄을 사용하십시오.

   print("SDK version \(FBSDKSettings .sdkVersion())")

나는 수입을 놓쳤다 FBSDKCoreKit. 나중에 시뮬레이터에서 작동하기 시작했지만 iPhone 장치에서는 작동하지 않았습니다.

또한 Facebook 사이트에서 다음 FAQ를 확인했습니다. 다음과 같은 콘솔 메시지가 표시되는 이유

'canOpenURL : URL'fb ... : // '실패

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

Regarding not working on the iPhone device, please refer: Parse API - Facebook login not working on the iPhone device


This is an Xcode warning indicating the the 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 Select Your App, And configure your info.plist

import And add this code in 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)
}

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

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


The issue is due to App Transport Security introduced in iOS 9.

There are two solutions, both deal with fixing your info.plist file

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


You need to add this method if your app is running on iOS9 or above.

- (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]];

}

In case 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)
}

I figured out my issue. It was just the syntax in loginButtonClicked function. The error message was leading me down 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)
            })
        }

        })
}

참고URL : https://stackoverflow.com/questions/32663382/facebook-login-issue-canopenurl-failed-for-url-fbauth2-error-null

반응형