FBSDK Login Error Code: 308 in Objective-C
IosFacebookParse PlatformFacebook Sdk-4.0Ios Problem Overview
I keep getting
> "Error Domain=com.facebook.sdk.login Code=308 "The operation couldn’t > be completed. (com.facebook.sdk.login error 308.)""
upon trying to login with Facebook from my device.
My code works on the simulator, but not on an actual device. Has anyone ran into this error code before? I'll be more than happy to share code upon request.
Ios Solutions
Solution 1 - Ios
The solution below works for iOS9 + running on Xcode 8, for Swift3.0
The steps are
- Setup Facebook Launch
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
- Setup Open Url
guard let source = options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String else { return false } let annotation = options[UIApplicationOpenURLOptionsAnnotationKey] as? String return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: source, annotation: annotation)
3. Fix Keychain permission issue as shown in the image below
Solution 2 - Ios
One solution, at least for me, is to not run on device via the Xcode debugger. If I run the app on device outside the debugger the Facebook login works fine. If I run the app in the sim via the debugger the Facebook login works fine.
Only if I run the app on device via the Xcode debugger do I get the com.facebook.sdk.login error 308 every time.
Solution 3 - Ios
You should enable Keychain Sharing on the Capabilities tab.
Solution 4 - Ios
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>
Solution 5 - Ios
I'm getting the exact same thing FB SDK 4.6.0 Xcode 7.0 iOS9. All the setup & instructions on the facebook developer site were followed to the letter. None of the above solutions worked for me. I'm finding that the behaviour is worse when you're deploying to the device live and feeding back to the Xcode console while doing the login procedure. It's really pot luck if it actually logs you in or not. It seems to behave in a more predictable way when you just re-launch your app cold after deployment. -Yes this is in fact the case!
When it decides to fail to login it results in the following error:
Error Domain=com.facebook.sdk.login Code=308 "(null)"
Solution 6 - Ios
My solution on Xcode7.1, Swift2.0
Step 1. Clean your build folder: option
+ command
+ K
or: Choose Product
> Clean
Solution 7 - Ios
I had the same problem and fixed it refreshing the system credentials
[FBSDKLoginManager renewSystemCredentials:^(ACAccountCredentialRenewResult result, NSError *error) {
[[[YourAuthManager manager] facebookLoginManager] logInWithReadPermissions:@[@"email"] fromViewController:nil handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
// Handle error
} else if (result.isCancelled) {
// Handle cancellations
} else {
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
if ([result.grantedPermissions containsObject:@"email"]) {
// Do work
}
}
}];
}];
This solution is less radical than reinstalling and you assure your users won't have to do it. My guess is that FBSDK 4.6 has some conflicts with iOS 9 system FB authentication credentials.
Edited: After some time testing it kept happening, not as often as before but it was still an issue, so we downgraded to a previous version of FB SDK. Hopefully someone finds a better solution.
Solution 8 - Ios
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.
Solution 9 - Ios
In my case it was fixed by updating to latest FB SDK. 4.10 at the moment.
Solution 10 - Ios
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.
Solution 11 - Ios
I was able to get login working again on iOS9 with SDK 4.6.0 by adding the new plist key/value
<key>FacebookDisplayName</key>
<string>{Your App Name}</string>
I also took the steps in some other answers here to implement a shared FBSDKLoginManager() instance.
Solution 12 - Ios
I was getting the same error on xcode 7.1 ios 9.1 FB SDK 4.7.1. .
Uninstalling, installing and testing without xcode works fine for the first time. This will allow you to plug back in the device and run it at least a couple of times (it seems to be a bit inconsistent...)
Solution 13 - Ios
Same problem FB SDK 4.5.1 and none of the above solutions worked for me.
I solved this by adding Bolts framework to project by drag & drop (from FacebookSDK directory)
and then adding bolts framework to appDelegate
#import <bolts/bolts.h>
Solution 14 - Ios
In the FBSDKDelegate Method loginButtonWillLogin put this
- (BOOL) loginButtonWillLogin:(FBSDKLoginButton *)loginButton{
[FBSDKAccessToken setCurrentAccessToken:nil];
return YES;}
Solution 15 - Ios
Updating to the latest (4.11) FB SDK fixed this for me as well. Don't forget to clean your project after updating to see if it works for you!
Solution 16 - Ios
To Resolve this issue you needs to just enable "Keychain Sharing" in capabilities.
Solution 17 - Ios
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.
Solution 18 - Ios
If you are using FBSDK 4.38 there is a bug with the parsing of challengeExpected in FBSDKLoginManager.m.
I found a hot fix of rinat-enikeev for it:
https://github.com/facebook/facebook-sdk-swift/issues/286
Just change
NSString *challengeExpected = [self loadExpectedChallenge];
to
NSString *challengeExpected = [[self loadExpectedChallenge] stringByReplacingOccurrencesOfString:@"+" withString:@" "];
Thats solved the issue for me.