Facebook integration in PhoneGap Android App

There are lots of plugin available for integrating Facebook in PhoneGap, however it is not a simple process, a successful integration needs many configurations to be done in the app as a first step.

This article will help in implementing the configurations needed to integrate Facebook in PhoneGap Android App.

If you have already created the PhoneGap app then skip Step1.

  1. Create a PhoneGap Android App.
  2. Create an App in Facebook.
  3. Generate a key hash for Facebook integration with android.
  4. Add generated key hash to Facebook App.
  5. Download a zip file of PhoneGap Facebook Connect plugin and extract.
  6. Browse to the project folder in command prompt and run
    cordova -d plugin add <path to the extracted PhoneGap Facebook Connect folder> –variable APP_ID=”<Facebook App ID >” –variable APP_NAME=”<Facebook App Name>”
  7. Now we can use available API commands in our code like FB Login, FB Logout, FB Get Status, FB Show Dialog, FB Graph API etc
Video tutorial coming soon, subscribe us on YOUTUBE

Generate a key hash for Facebook integration with android using openssl

Facebook uses the key hash to authenticate interactions between your app and the Facebook app. If you run apps that use Facebook Login, you need to add your Android development key hash to your Facebook developer profile.

This article share the process of generating a key hash for Facebook integration with android using openssl

  1. Download openssl from Google code (If you have a 64 bit machine you must download openssl-0.9.8e X64 not the latest version)
  2. Extract it. create a folder- OpenSSL in C:/ and copy the extracted code here.
  3. Detect debug.keystore file path. If u didn’t find, then do a search in C:/ and use the Path in the command in next step.
  4. Find the keytool path which is in Jre directory. (C:Program FilesJavajre7bin)
  5. Detect your keytool.exe path and go to that dir/ in command prompt and run this command in 1 line

    keytool -exportcert -alias androiddebugkey -keystore “C:Documents and SettingsAdministrator.androiddebug.keystore” – “C:OpenSSLbinopenssl” sha1 -binary |”C:OpenSSLbinopenssl” base64

* it will ask for password, put android
* that’s all. u will get a key-hash
Video tutorial coming soon, subscribe us on YOUTUBE

Creating your first Android App using PhoneGap Command Line Interface.

So now you have installed PhoneGap/Cordova and Android development tools in your windows machine as explained here , now you can proceed with Android App development by reading this article :

All the steps below will use CLI commands available with PhoneGap/cordova, you can read about using CLI commands here.

  1. Create a PhoneGap Project
    Command : phonegap create project_folder app_id app_name
    eg : phonegap create my_first_app My first App
  2. Add Android Platform
    Command : phonegap platform add platform_name
    eg. : phonegap platform add android
  3. Build the Android App with default files
    Command : phonegap build platform_name
    eg. : phonegap build android
  4. Emulate the Android App
    Command : phonegap emulate platform_name
    eg. : phonegap emulate android
While following this process if you get stuck due to some errors, check this article