TrinityTuts

Facebook integration in iOS

Last updated on July 31st, 2016 at 11:13 am

Facebook integration is very important feature now a days . It is seen in almost every application for direct login.  Before starting Facebook integration in your iOS application , you first need to create a new application in Facebook developers account.

Step 1 : Go to developers.facebook.com and login your Facebook developers account.

  1. Download iOS SDK for Facebook Integration.
  2. Create a Facebook App on the developers account so that Facebook will know that you want to integrate Facebook in your application.
  3. Fill in the name of the app and choose its type . Click on create application.

Step 2 :  Choose your platform

After you create Facebook app in the developers account  , choose the platform to iOS.

Step 3 : Add Facebook SDK to your project .

  1. Drag FBSDKCoreKit and FBSDKLoginKit to your projects bundle and uncheck copy to destination folder.
  2.  Go to yours project build settings and in the framework search paths add the path of the folder where you have downloaded the Facebook SDK. eg. /Users/Saurab-01M/Desktop/Saurabh/FacebookSDKs-iOS-20151111.
  3. Add your appBundleID in the Facebook web .

Step 4 : Update info.plist of your application

  1. Open info.plist of your application by clicking on info.plist in app bundle.
  2. Right click on info.plist and choose Open as >> Source code and add the code from Facebook developers website between <dict> and </dict>  in your plist file.

This will add the Facebook`s app id and Transport settings to your application.

Step 5 : Make changes in the appDelegate.m to connect the Facebook to your application

1) Import FBSDKCoreKit/FBSDKCoreKit.h in appDelegate.h .

2) Add the Facebook Delegate in the DidFinish launching with options of AppDelegate.m as

3) After didFinishLauching , add the following code to the appDelegate.m

Step 6 : Import the frameWorks in ViewController .m file as

#import <FBSDKLoginKit/FBSDKLoginKit.h>

#import <FBSDKCoreKit/FBSDKCoreKit.h>

Now , update your ViewController.m by adding following code to add a login button and access name , email and access token  through Facebook 

Output

Facebook integration is completed . For more blogs related iOS development visit codeObjectiveC.blogspot

Thank you 🙂

Facebook integration in Android