Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting com.facebook.sdk.login error 308?

I am using Xcode 7.0, testing on iOS 9.0.2 and using Facebook SDK 4.7.0.

When I am logging in a user, most of the time everything works as it should, however sometimes I keep getting this error and I have no idea why!

The operation couldn’t be completed. (com.facebook.sdk.login error 308.)

After researching I have seen that some people are getting the error when logging in with parse.com's FBUtils and the official FBSDK at the same time, however I am only using FBSDK in my project.

So my question is, why am I getting this error and how do I get rid of it?

Edit - Adding Code

Here is my login logic:

func loginWithFacebook(sender: UIViewController, completion: (profile: FBSDKProfile?, token: String?, cancelled: Bool, error: String?) -> Void ) {      FBSDKProfile.enableUpdatesOnAccessTokenChange(true)     NSNotificationCenter.defaultCenter().addObserver( sender , selector: "onProfileUpdated:", name:FBSDKProfileDidChangeNotification, object: nil)     let loginManager = FBSDKLoginManager()     loginManager.logInWithReadPermissions(["email", "public_profile"], fromViewController: sender) { (result: FBSDKLoginManagerLoginResult!, error: NSError!) -> Void in         if error != nil {             print("ERROR")             completion(profile: nil, token: nil, cancelled: false, error: error.localizedDescription)             print(error.localizedDescription)          } else if result.isCancelled {             print("CANCELLED")             completion(profile: nil, token: nil, cancelled: true, error: nil)          } else {             print("NO ERROR")             if FBSDKProfile.currentProfile() == nil {                 print("PROFILE IS NIL")                 completion(profile: nil, token: result.token.tokenString, cancelled: false, error: nil)             } else {                 print("PROFILE IS NOT NIL")                 completion(profile: FBSDKProfile.currentProfile(), token: result.token.tokenString, cancelled: false, error: nil)             }          }      } } 
like image 739
Swinny89 Avatar asked Oct 22 '15 15:10

Swinny89


People also ask

What is the Facebook SDK?

The Facebook SDK is a set of software components that developers can include in their mobile app to understand how people use the app, run optimized marketing campaigns and enable Facebook login and social sharing. This course helps you understand the purpose of the Facebook SDK and App Events for Android and iOS.


1 Answers

For Xcode8 - iOS10,

Enable Keychain Sharing within Capabilities tab of target fixed my issue.

enter image description here

More details can be found here : https://github.com/facebook/facebook-sdk-swift/issues/51


For Xamarin Studio (Suggested by @Kenneth),

Add the Entitlements.plist file to Custom Entitlements under the iOS Bundle Signing options in the iOS project.

like image 132
Mohammad Zaid Pathan Avatar answered Oct 01 '22 23:10

Mohammad Zaid Pathan