每次我嘗試用Facebook最近登錄時,它都不起作用,它顯示下面的錯誤。這發生在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文件 –
我想你忘記實現在AppDelegate類FUNC applicationDidBecomeActive這種方法是什麼(_應用:UIApplication的){ FBSDKAppEvents.activateApp() } –