Cordoba / Telephone: Cannot Connect to Facebook Phonegap Plugin

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 --variable APP_ID="1415347585409217" --variable APP_NAME="Test" vi www/index.html # Add: alert(typeof facebookConnectPlugin); to the last <script> cordova emulate ios 

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:

 <!-- fb-root is needed by the FB API. --> <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) { // Initialize - only executed when testing in the browser. facebookConnectPlugin.browserInit(308939305080); } } </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 
+6
source share
2 answers

Add: alert(typeof facebookConnectPlugin); to the last <script>

It behaves as expected, believe it or not.

Plugins are not available until the deviceready event deviceready : http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready

Try checking facebookConnectPlugin on the onDeviceReady generated www/js/index.js instead of the tag that was immediately launched?

+7
source

Hi guys, I found something new to integrate with Facebook in the note taking app on the phone. Without any plugins for Facebook you can use the functions of Facebook, for this use phonegap.facebook.inappbrowser.js, using this js, you can easily access all the functions of Facebook for more information visit this URL: Facebook integration Step without any plugins

+2
source

Source: https://habr.com/ru/post/972600/


All Articles