且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 iOS 10 上使用 Facebook iOS SDK

更新时间:2022-11-01 16:57:16

Error OSStatus -10814canOpenURL:

如果您使用的是 Xamarin(阅读此链接了解更多信息,谢谢@dynamokaj):

只要确保您在权利和也选择模拟器(调试)构建的权利.默认情况下未设置.

I am trying to use Xcode 8 to build a app with Facebook login using Swift 3. When I switch back iOS Simulator 9.3, it works. In iOS 10, I receive this error:

""fbauth2:/" The operation couldn’t be completed. (OSStatus error -10814.)"

and

Optional(Error Domain=com.facebook.sdk.login Code=308 "(null)")

Anyone have solution for this?

Note 1 :

After debugging, this problem is FBSDK cant update expect_challange. Function SecItemUpdate inside security.framework not work. This is a problem of IOS 10

Error OSStatus -10814 occures when canOpenURL: can't find any application, that can open this URL (actually, Facebook trying to find their application 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.

Error 308 occures because of the situation, when value, stored in keychain is not equal to value, that is stored in facebook completion parameters (for more information you can check -[FBSDKLoginManager completeAuthentication:expectChallenge:]).

It happens because Apple changed the way of working with keychain in iOS 10. To fix this issue you simply should go to Targets->Capabilities and enable keychain sharing (it enables access to keychain for your app):

If you are using Xamarin (read this link for more information, thanks @dynamokaj):

Just make sure you enable the keychain access in Entitlements and select the entitlements for Simulator (Debug) builds too. By default this is not set.