11

I am getting "com.facebook.FBiOSSK error 2" error when ever try to login with my app by using device.But its working fine with the simulator.

I am using iOs SDK 3.0 Beta. any solutions?

name-it
  • 2,238
  • 3
  • 19
  • 28

7 Answers7

15

I had the same problem on authententication with "com.facebook.sdk error 2". And i think solved it on my part. Just make sure on your app definition on "https://developers.facebook.com/apps/.." on "IOS Bundle ID " section, that you put your app id like this com.domainname.appName and not X792739.com.domainname.appName

j0k
  • 22,600
  • 28
  • 79
  • 90
  • This is the correct answer. I was using a bundle id from my developer portal (so that I can run on the device) while the Facebook app on developer.facebook.com has the client's bundle id. – Mugunth Aug 25 '12 at 07:04
  • I second @Mugunth This is the correct answer ... I had not configured the app correctly on Fb.com/apps. Works like a charm now. – Ephraim Dec 15 '12 at 20:32
13

Yes, after you see this error, if you go to Settings, you will see that the setting for this app is turned "OFF". But the problem in this case is that the user was never prompted to allow access -- i.e. the setting was turned to OFF automatically on first time access. If the user was asked, then of course that is understandable, but this is not the case (it's as if the SDK silently and automatically pressed Don't Allow for the user). That's why this is a problem.

Before you read any further, I want to note that once the setting is set, you cannot simply repeat the process to test it, because once the setting is set, it will never ask the user (even deleting and reinstalling the app does not help). To test this issue, you need to reset the permissions by going to Settings -> General -> Reset -> Reset Location & Privacy, before you can try to replicate this again.

From testing, I've discovered that if you have offline_access in the permissions you are requesting for the first time, then it will give this login error (and not prompt the user and set the permission to OFF). The SDK does not check and tell you that this permission is not allowed; it just fails to login.

user102008
  • 30,736
  • 10
  • 83
  • 104
  • I had this problem. Removed the offline_access permission and resetted my location & privacy settings and it works! Really annoying – Jovan Oct 23 '12 at 12:07
  • for me, the issue was definitely asking for offline_access. After removing that, error 2 went away. thanks for the tip! – John Apr 22 '13 at 14:49
8

We were seeing the com.facebook.sdk error 2 error only for certain people. The problem ended up being that our Facebook App was still in Sandbox Mode. Disabling that at developers.facebook.com/apps/{ourfacebookid} instantly fixed the problem.

Turns out it was working for those of us who were set up as admins for the FB App, but not anyone else.

leontx
  • 1,165
  • 1
  • 14
  • 24
  • That just cost me 3 hours of debugging, going back and forth in our revisions. And, you saved several more hours of struggle, thx, upvoted! – mentat Dec 21 '12 at 14:05
5

This error is received when the user chooses "Don't Allow" when asked to give the app permissions.

I suggest that you replace the default error message (copied from Facebook SDK sample code) with a user friendly message, telling him to make sure he granted your app the required permissions.

To fix this at iOS 6, go to Settings -> Facebook and turn your app's switch ON.

Kof
  • 23,893
  • 9
  • 56
  • 81
  • where do you do this exactly? – ohayon Jan 30 '13 at 16:35
  • At `sessionStateChanged:state:error:` callback method you implement in your delegate. If you receive an error, don't show it to the user, show a message that tells him to make sure he granted the required permissions. – Kof Feb 11 '13 at 13:23
  • Thanks. This works. Doesn't solve the problem, but at least allow me to inform users – honcheng Feb 27 '13 at 07:36
1

I got the same problem when I tried to follow the tutorial (http://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/authenticate/)

It seems to work fine when I followed the instruction in the 'howto' section, and it's a little bit different : https://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/

1

I faced with the same problem. It turns out that if the Sandbox is enabled than the users should be admin. If it is disabled then works for everyone.

Shirish Kumar
  • 1,532
  • 17
  • 23
0

In my case this error was the result of asking for 'publish_actions' permissions at authentication. Write permissions have to be gotten separately: https://developers.facebook.com/docs/tutorial/iossdk/upgrading-from-3.0-to-3.1/