Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Facebook iOS SDK on iOS 10

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

like image 300
trquoccuong Avatar asked Aug 01 '16 00:08

trquoccuong


People also ask

What version of iOS does Facebook need?

Requires iOS 13.4 or later.

What is the Facebook SDK for iOS?

The Facebook SDK for iOS contains component SDKs that you can connect to individually. Drive installs with Mobile App Install Ads. Increase engagement with Mobile App Engagement Ads.

How do I update the Facebook SDK for my App?

If you use SPM or CocoaPods to integrate the Facebook SDK, see the Upgrade Guide for information on how to update your app. You can also download the latest version of the Facebook iOS SDK, integrate it into your app, and recompile.

How do I Make my app compatible with the latest iOS?

To make your app compatible with the latest iOS, be sure to use the latest Facebook SDKs for iOS. If you link to the SDKs with CocoaPods, you must update your pods for the SDKs your app uses and recompile your app. You can also download the latest version of the Facebook iOS SDK, integrate it into your app, and recompile.

What is Facebook-iOS-SDK on GitHub?

GitHub - facebook/facebook-ios-sdk: Used to integrate the Facebook Platform with your iOS & tvOS apps. This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Failed to load latest commit information. Remove the publish_cocoapods step from CircleCI since its not possibl…


3 Answers

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): image

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.

like image 89
Roman Ermolov Avatar answered Oct 20 '22 17:10

Roman Ermolov


Same problem was in my app, i checked many solution but did't works for me. I've fix this problem using below method.

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)
}
like image 32
ZAFAR007 Avatar answered Oct 20 '22 19:10

ZAFAR007


The main reason why you're getting the following error,

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

is that your iOS simulator does not have the Facebook Application installed. Until you install the application on your iOS simulator, you will continue to get the error. Try running your iOS application on a provisioned iOS device with Facebook installed and you will not see the error message again. Hope this helps!

like image 4
umarqattan Avatar answered Oct 20 '22 19:10

umarqattan