Facebook Cordova Integration - aaccurso/CostSplitter GitHub Wiki

Prerequisites: FB App created with Website and Android platforms added to its configuration.

Based on phonegap-facebook-plugin guide release 0.4.2.

Install phonegap-facebook-plugin

First add the plugin with cordova cli:

cordova plugin add https://github.com/phonegap/phonegap-facebook-plugin.git#0.4.2 \
  --variable APP_ID="<your_facebook_app_id>" \
  --variable APP_NAME="<your_facebook_app_name>"

How to add specific release of a plugin.

Open \plugins\com.phonegap.plugins.facebookconnect\plugin.xml and replace this:

<preference name="APP_ID" />
<preference name="APP_NAME" />

with this:

<param name="APP_ID" value="<your_facebook_app_id>" />
<param name="APP_NAME" value="<your_facebook_app_name>" />

Build Android application:

cordova platform add android && cordova build android

Generate a hash-key of your debug.keystore with password 'android' (required):

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore \
  | openssl sha1 -binary | openssl base64

Copy the key and paste it under your FB app Android configuration in the 'Android Key Hash' section: Android Key Hash

Add this into www/config.xml widget tag:

<feature name="org.apache.cordova.facebook.Connect">
    <param name="android-package" value="org.apache.cordova.facebook.ConnectPlugin" />
</feature>

TODO:

  • Add cdv-plugin-fb-connect.js to index.html
  • Explain if CDV else end

Install Facebook SDK for Android

Facebook APK installation is only applicable if you are using the emulator to test the app

  1. Download and install Facebook SDK: https://developers.facebook.com/docs/android/getting-started#install

  2. Install Android plugin for Eclipse (yes, it's necessary to install Eclipse): http://developer.android.com/sdk/installing/installing-adt.html

  3. Import FB SDK and your Project into Eclipse.

  4. Link FB SDK to your Project. Go to Properties -> Android -> ( Library -> Add -> FacebookSDK ) -> OK

  5. Update facebook sdk project: android update project -p $FACEBOOK_SDK/facebook

  6. Add this to app's AndroidManifest.xml: <activity android:name="com.facebook.LoginActivity" android:label="@string/app_name" />

  7. IMPORTANT: Remove com.facebook.android from project /src.

  8. Run as Android App from Eclipse.

TODO: script or grunt task (on root directory) with

cordova prepare android && cd platforms/android && ant clean && ant debug install

(redirect output to log file)


Facebook Login

https://developers.facebook.com/docs/android/getting-started#login

⚠️ **GitHub.com Fallback** ⚠️