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.
- Download iOS SDK for Facebook Integration.
- Create a Facebook App on the developers account so that Facebook will know that you want to integrate Facebook in your application.
- 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 .
- Drag FBSDKCoreKit and FBSDKLoginKit to your projects bundle and uncheck copy to destination folder.
- 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.
- Add your appBundleID in the Facebook web .
Step 4 : Update info.plist of your application
- Open info.plist of your application by clicking on info.plist in app bundle.
- 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
Now , update your ViewController.m by adding following code to add a login button and access name , email and access token through Facebook
Facebook integration is completed . For more blogs related iOS development visit codeObjectiveC.blogspot
Thank you 🙂