Setup FB on your phonegap application

Posted By : Deepak Rawat | 26-Jun-2015

Create Facebook app

 

If app is not registered with facebook and has App ID, You should create it

 

Create New app

 

And fill each section for app

 

 

  • Bundle ID - iOS bundle ID corresponds to app

  • iPhone App Store ID -  App Store ID

  • iPAD App Store ID - iPad App Store ID if app in app store

 

After create app, Facebook App ID appears at top of dashboard page

 

 

Next set bundle identifier and configure your facebook application to support login from an iOS application

 

  1. Select settings in Application dashboard.

  2. Click add platform and select iOS.

  3. Provide bundle identifier in the Bundle id field.

  4. Enable single sign on

  5. Click save changes.

 

 

You can set bundle identifier in Xcode in Project tab.

 

 

Configure an Xcode Project

 

Add SDK for iOS to project and configure .plist file

 

Add the SDK

 

Facebook SDK for iOS is framework that add to Xcode project.

 

  1. Open /Documents/FacebookSDK

  2. Drag FBSDKCoreKit . framework to Frameworks in Project Navigator.

  3. Select create groups for any added folders

  4. Deselect copy items into destination group's folder.

 

 

SDK automatically loads it framework and resource dependencies

 

Now configure .plist for your project

 

  1. Create a key called FacebookApp id  with string value, and add app ID there

  2. Create key called FacebookdisplayName with string value and add display name configured in App dashboard

  3. Create array key called URL types with single array sub-item called URL schemes. Give this single item with App ID prefixed with fb

 

It used to confirm application with receive callback URL of web-based OAuth flow

 

Finished .plist look like this

 

 

Note: For phonegap application you need to install the FB plugin using “cordova plugin add https://github.com/Wizcorp/phonegap-facebook-plugin/” the Xcode configuration and the FB SDK will automatically get configured.


 

About Author

Author Image
Deepak Rawat

Deepak is a Web and Mobile application Sr. Lead Frontend developer and good working experience with JQuery , AngularJS , Javascript and PhoneGap. His hobbies are listening to music and photography.

Request for Proposal

Name is required

Comment is required

Sending message..