Search code examples
iosfacebook-ios-sdk

Facebook iOS 3.1 SDK: can login with Safari but not natively


I'm integrating the iOS 3.1 Facebook SDK. When implementing a login with Facebook feature, I call FBSession openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:. When called on the simulator (where I don't have a FB account set up natively) I can successfully login.

However, from a device with a native Facebook account setup, when calling openActiveSessionWithReadPermissions... the session type returned in the completion handler is always sessionStateClosedLoginFailed, regardless of whether I allow or disallow my app to use Facebook in the alert dialog. The session state before calling the method is sessionStateCreated.

This is the NSError from the completion handler: Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0x20a80820 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorLoginFailedReason, com.facebook.sdk:ErrorInnerErrorKey=Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No value.) UserInfo=0x208ed930 {NSDebugDescription=No value.}}

What am I doing wrong that would cause this problem?

Update: I just noticed that my app is not appearing in the Settings > Facebook > "Allow these apps to use your account' section. (It was definitely there earlier today).

Update2: If I delete my account from the iOS Settings app, and then log my test user into the Facebook iPhone app, I am able to login with fast app switching. So it appears to only be a problem with the native account.

Update3: I ran the sample Facebook app Scrumptious I have the same problem. Upon clicking 'Login', which calls the openActiveSessionWithRead... I get the same error.

Update4: Possibly related to this bug? http://developers.facebook.com/bugs/450137751688028?browse=search_50a43a39b37ae4868318658

Update5: I should have mentioned this earlier, but it was a Facebook test user account that had this problem.


Solution

  • I switched from using a Facebook test user account to a regular account and this solved the problem on both the Scrumptious app and my app.