iOS Facebook Login Tutorial

mikeholp picture mikeholp · Sep 1, 2013 · Viewed 19.9k times · Source

How to integrate Facebook login into an iOS app, for ALL versions?

I've scoured Google and GitHub for hours on end without a complete solution. I've also read all the documentation at Facebook and dissected the ios-facebook sample code. I have a working version for >=iOS6 but anything below that will crash (ACAccountStore doesn't exist). Currently I'm using a library called LBFacebook to login. The only downside is, again, it doesn't work for iOS5.

I'm pulling my hair out. The FacebookSDK changes every couple weeks. It would be miraculous to get this working once and for all.

Answer

Joel picture Joel · Sep 1, 2013

The Facebook SDK 3.1 is backwards compatible. It tries to authenticate in this order:

  1. Account Framework (ACAccount)
  2. Via the Facebook app (if installed)
  3. Via a web browser (old way)

I can confirm it works fine for me in older iOS version. If you are getting an error that ACAccountStore doesn't exist, you are doing something wrong. From the documentation:

If you haven't logged in before, depending on your version of iOS, you'll see the native login modal dialog box, be redirected to the Facebook for iOS or be redirected to Facebook in Safari to complete the auth flow.

See here. They show a picture of what it looks like in different iOS versions.

For complete tutorial see here.