2017-04-27 17 views
0

最近フェイスブックでログインしようとするたびにうまくいかず、以下のエラーが表示されます。これは、iOSシミュレータと実際のデバイスで発生します。iOS Xcode 8.3 Facebook SDKログインエラー

2017-04-27 10:18:04.361 Colour Confuse[43796:1851249] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" 2017-04-27 10:18:04.362 Colour Confuse[43796:1851249] Falling back to storing access token in NSUserDefaults because of simulator bug 2017-04-27 10:18:04.363 Colour Confuse[43796:1851249] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

それは、私はそれが次のエラーをスローして、ビューが空白になり続けるためにクリックしたときただし、ユーザがログインできるようにするためのViewControllerを示しています。 FB View Controllerを閉じるために「完了」を押すと、アプリが完全にクラッシュしました。

Facebook login was cancelled by user. 2017-04-27 10:18:07.346 Colour Confuse[43796:1851249] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" 2017-04-27 10:18:07.346 Colour Confuse[43796:1851249] Falling back to storing access token in NSUserDefaults because of simulator bug 2017-04-27 10:18:07.347 Colour Confuse[43796:1851249] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" 2017-04-27 10:18:07.876 Colour Confuse[43796:1851249] Warning: Attempt to present <FBSDKContainerViewController: 0x7fe74da048c0> on <Colour_Confuse.GameViewController: 0x7fe74db02d80> whose view is not in the window hierarchy!

それは数日前までは正常に動作していますし、私はちょうど私が何も変わっていないとして、それはsuddently動作を停止している理由についての見当もつかない。

let facebookLogin = FBSDKLoginManager() 
facebookLogin.logIn(withReadPermissions: ["email", "user_friends", "public_profile"], from: self.view?.window?.rootViewController) { (result, error) in 
     if result?.isCancelled == true { 
      self.fbLoginError() 
     } else if error == nil { 
      let credential = FIRFacebookAuthProvider.credential(withAccessToken: (result?.token.tokenString)!) 
      FIRAuth.auth()?.signIn(with: credential, completion: { (user: FIRUser?, error:Error?) in 
       if error == nil { 
        print("FB and Firebase Login Successful") 

        }) 
       } else { 
        print(error) 
        self.fbLoginError() 
       } 
      }) 
     } else { 
      print(error) 
      self.fbLoginError() 
     } 
    } 

AppDelegate

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

    FBSDKProfile.enableUpdates(onAccessTokenChange: true) 

    FIRApp.configure() 

    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) 

    return true 
} 


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


    func applicationDidBecomeActive(_ application: UIApplication) { 
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 

    FBSDKAppEvents.activateApp() 

} 

それはif文とちょうど完了クロージャ内のすべて無視のいずれかに当たることはありません。私はまた、キーチェーンの共有が

PLIST

PLIST

+0

あなたが –

+0

を試していたものいくつかのコードを表示することができますあなたはplistファイル –

+0

を表示することができます私はあなたがappdelegateクラスのfunc applicationDidBecomeActiveでこのメソッドを実装するのを忘れ考える(_アプリケーション:のUIApplication){ FBSDKAppEvents.activateApp() } –

答えて

0

を有効にしている

は次のように試してみてください!

Appdelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
     FIRApp.configure() 
    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) 
    } 

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { 
    let handled = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options) 
    return handled 
} 
func applicationDidBecomeActive(_ application: UIApplication) { 
    FBSDKAppEvents.activateApp() 
} 

ViewController.swift

@IBAction func facebookLogin(sender: UIButton) { 
    let fbLoginManager = FBSDKLoginManager() 
    fbLoginManager.logIn(withReadPermissions: ["public_profile", "email"], from: self) { (result, error) in 
     if let error = error { 
      print("Failed to login: \(error.localizedDescription)") 
      return 
     } 

     guard let accessToken = FBSDKAccessToken.current() else { 
      print("Failed to get access token") 
      return 
     } 

     let credential = FIRFacebookAuthProvider.credential(withAccessToken: accessToken.tokenString) 

     // Perform login by calling Firebase APIs 
     FIRAuth.auth()?.signIn(with: credential, completion: { (user, error) in 
      if let error = error { 
       print("Login error: \(error.localizedDescription)") 
       let alertController = UIAlertController(title: "Login Error", message: error.localizedDescription, preferredStyle: .alert) 
       let okayAction = UIAlertAction(title: "OK", style: .cancel, handler: nil) 
       alertController.addAction(okayAction) 
       self.present(alertController, animated: true, completion: nil) 

       return 
      } 

      // Present the main view 
      if let viewController = self.storyboard?.instantiateViewController(withIdentifier: "MainView") { 
       UIApplication.shared.keyWindow?.rootViewController = viewController 
       self.dismiss(animated: true, completion: nil) 
      } 

     }) 
    } 
} 

のInfo.plist を挿入し、次のXMLスニペット

<key>CFBundleURLTypes</key> 
<array> 
    <dict> 
    <key>CFBundleURLSchemes</key> 
    <array> 
     <string>fb1249988161716400</string> 
    </array> 
    </dict> 
</array> 
<key>FacebookAppID</key> 
<string>1249988161716400</string> 
<key>FacebookDisplayName</key> 
<string>YourString</string> 
<key>LSApplicationQueriesSchemes</key> 
<array> 
    <string>fbapi</string> 
    <string>fb-messenger-api</string> 
    <string>fbauth2</string> 
    <string>fbshareextension</string> 
</array> 
+0

こんにちは、私はこれをSKSceneから実行しています。何ヶ月もうまく働いています。昨日は仕事が止まったときだけです。上記のコードを実装した後も、同じエラーと警告がスローされます。 – Ryann786

+0

@ Ryann786あなたが実装しているコードは昨日から動作していなかった –

+0

私が作った唯一の違いは、私のアプリからログアウトして再び新しいユーザーをテストすることに戻りました。ログインコード。 – Ryann786

関連する問題