Tuesday, January 4, 2011

Facebook single sign on in iOS


Facebook has added some new APIs in its API collection. These new APIs are Graph API.
Graph API provide a simple method to access the information, feeds, friends list, posts,pages etcs of the user.

Single Sign On (SOS) is something that will enable the application to launch the existing Facebook application on the HH (Hand Held) through the third party application.

When a user clicks on share or login button in your application, the application will invoke the facebook application installed on the device to authorize the user. User will enter his credentials in the facebook application and on successful (or unsuccessful) authorization, facebook application will open back the application he was into with proper message.

Thus, with Single Sign On, if the user is logged in once, he need not provide the credential again and again ( as the credentials are stored in native facebook application on device).

Also if the OS available is less than the version that supports background application ie. iOS 4.0, simple FBConnect dialogue will appear for authentication and authorization.

To enable Single Sign On in your application, all you need is to handle

– (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url

method in the appdelegate of the application and add the URL scheme information in the .plist file of your application.

For more guidelines ,steps and facebook SDK for iOS, please visit:here
Happy Coding…

3 comments:

  1. Hello Saroj, great informative post about single-sign on for iOS. Is it possible to provide some sample code for the:

    – (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url

    method? I was a little confused about what to do in the appdelegate and what to add in the URL scheme in the plist file. Thanks.

    ReplyDelete
  2. Hi Kofi,
    Sample code is available at, https://github.com/facebook/facebook-ios-sdk . It has the handling of handleOpenURL and others too.

    ReplyDelete
  3. Can we use single sign on with FBGraphapi. in ur blog it's working with facebook ios sdk.

    ReplyDelete