I keep getting
\"Error Domain=com.facebook.sdk.login Code=308 \"The operation couldn’t be completed. (com.facebook.sdk.login error 308.)\"\"
Did some digging around in FBs code and it looks like this is simply an entitlements issue.
FB uses the keychain to store an authorization challenge during login. When returning it attempts to get the value from the keychain and fails. See this SO answer for more info.
Security entitlements can change between provisioning profiles, and as we all know, keeping our profiles and build configurations and devices/sims straight is like herding cats. This could explain why people experience such inconsistent behavior.
So it might be safe to assume that in a production environment, everything will work fine, and if things aren't working during testing then you need to double-check the entitlements on your provisioning profiles.
I fixed the problem by uninstalling the app and re-installing and it worked right away.
The error is probably related to iOS 9. Since iOS 9, I think the SDK uses SafariViewController and it seems to create issues when you are already logged.
To Resolve this issue you needs to just enable "Keychain Sharing" in capabilities.
I had exactly the same problem and was able to find the solution by modifying the Info.plist
I've added all the possible schemes to LSApplicationQueriesSchemes
The complete list looks like this:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fb</string>
<string>fb-messenger-api20140430</string>
<string>fb-messenger-platform-20150128</string>
<string>fb-messenger-platform-20150218</string>
<string>fb-messenger-platform-20150305</string>
<string>fb-messenger-api</string>
<string>fbshareextension</string>
</array>
In my case it was fixed by updating to latest FB SDK. 4.10 at the moment.
I followed Suraj Pathak with Xcode 9.4.1 and Swift 4.2
Add to AppDelegate didFinishLaunchingWithOptions
SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
Add to AppDelegate delegate function
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return SDKApplicationDelegate.shared.application(app, open: url, options: options)
}
Allow Keychain in Capabilities.