Facebook Connect

Unofficial plugin (forked from the official one) for Facebook in Apache Phonegap.
bait-sk0.4.00
platforms: android,ios
$ cordova plugin add com.tickk.plugins.facebookconnect

Facebook plugin

This plugin is mainly a fork of @phonegap/phonegap-facebook-plugin and it is accomodated for Phonegap >=3.0, and cleaned up a little bit, and accomodated for our needs. So it is not official, and we cannot guarantee it will work properly for your needs. It does not include Facebook SDK. Supports Android and iOS.

INSTALLATION GUIDE

ANDROID

First you will need Facebook SDK Then you need to include the SDK into your Ant build: edit your local.properties file and add android.library.reference.1=../relative/path/to/facebook-android-sdk-3.5.2/facebook/

Then add the plugin to your phonegap project:

phonegap local plugin add https://github.com/bait-sk/cordova-plugin-facebook.git

iOS

  1. Download the latest Facebook SDK for iOS from the iOS Dev Center.
  2. Add the Facebook SDK for iOS Framework by dragging the FacebookSDK.framework folder from the SDK installation folder into the Frameworks section of your Project Navigator.
  3. Choose 'Create groups for any added folders' and deselect 'Copy items into destination group's folder (if needed)' to keep the reference to the SDK installation folder, rather than creating a copy.
  4. Add the Facebook SDK for iOS resource bundle by dragging the FacebookSDKResources.bundle file from the FacebookSDK.framework/Resources folder into the Frameworks section of your Project Navigator.
  5. As you did when copying the Framework, choose 'Create groups for any added folders' and deselect 'Copy items into destination group's folder (if needed)'
  6. Add the headers by dragging the DeprecatedHeaders folder from the FacebookSDK.framework/Versions/A/DeprecatedHeaders folder into the Frameworks section of your Project Navigator.
  7. Choose 'Create groups for any added folders' and deselect 'Copy items into destination group's folder (if needed)'. This adds the headers as a reference.
  8. Click on your project's icon (the root element) in Project Navigator, select your Project, then the Build Settings tab, search for Other Linker Flags.
  9. Add the value -lsqlite3.0
  10. Add the value -ObjC
  11. Click on your project's icon (the root element) in Project Navigator, select your Target, then the Build Phases tab, then the Link Binary With Libraries option.
  12. Add the Social.framework framework. Make it an optional framework to support pre iOS6 apps.
  13. Add the Accounts.framework framework. Make it an optional framework to support pre iOS6 apps.
  14. Add the AdSupport.framework framework. Make it an optional framework to support pre iOS6 apps.
  15. Add the Security.framework framework. Make it an optional framework to support pre iOS6 apps.

Then add the plugin to your phonegap project:

phonegap local plugin add https://github.com/bait-sk/cordova-plugin-facebook.git

Then you will need to update your *-Info.plist file of the project and add following parameters:

<FacebookAppID>
    <string>$APP_ID</string>
</FacebookAppID>

<FacebookDisplayName>
    <string>$APP_NAME</string>
</FacebookDisplayName>

<CFBundleURLTypes>
<dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>fb$APP_ID</string>
    </array>
</dict>
</CFBundleURLTypes>

Replacing $VARS with respective values.

EXAMPLE OF USAGE

For now the JS files provided aren't exported as global modules, so you have to include both cdv-plugin-fb-connect.js and facebook-js-sdk.js as script tags.

Initialize plugin upon deviceready event, replace 1234567890123456789 with your facebook app id.

document.addEventListener('deviceready', function() {
    try {
        alert('Device is ready! Make sure you set your app_id below this alert.');
        FB.init({ appId: "1234567890123456789", nativeInterface: CDV.FB, useCachedDialogs: false });
        document.getElementById('data').innerHTML = "";
    } catch (e) {
        alert(e);
    }
}, false);