I tried to create a Cordova / Phonegap application and add the Facebook plugin, but alert (typeof facebookConnectPlugin); shows undefined:
sudo npm install -g cordova cordova create hello com.example.hello HelloWorld cd hello cordova platform add ios cordova -d plugin add https://github.com/phonegap/phonegap-facebook-plugin
Expected: The emulator shows an “Object” in the alert dialog box.
In fact: the emulator shows "undefined" in the alert dialog.
Does anyone know what I'm doing wrong?
UPDATE: Thanks to Devgeeks for his answer below.
Here are a few other things I need to do to get it working:
1) Install a new plug-in branch "develop":
cordova -d plugin add "https://github.com/phonegap/phonegap-facebook-plugin#develop" --variable APP_ID="1415347585409217" --variable APP_NAME="Test"
2) Add the opening tag below:
<div id="fb-root"></div>
3) If you want the FB-login to work in the browser (for testing), copy www / js / facebookConnectPlugin.js to your application. Then include it before the closing tag:
<script src="facebookConnectPlugin.js"></script>
Then add the following to your section:
<script> window.fbAsyncInit = function () { if (!window.cordova) { </script>
If you get "This URL is not allowed by the application configuration: one or more of the specified URLs is not allowed in the application settings. It must match the URL of the website or canvas, or the domain must be a subdomain of one of the application domains.", edit facebookConnectPlugin.js and change sdk.js to sdk / debug.js.
4) If, when creating an Android application, you get the following:
sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var
try running the following (from Issue 432 ):
cp platforms/android/local.properties platforms/android/FacebookLib