PhoneGap Adds Facebook Connect Plugin

I want to add com.phonegap.plugins.facebookconnect

to Android PhoneGap app, but I cannot do it. In the doc site they say add

<gap:plugin name="com.phonegap.plugins.facebookconnect">
    <param name="APP_ID" value="..." />
    <param name="APP_NAME" value="..." />
</gap:plugin>

      

in config.xml

but there are 3 config.xml

files in the PhoneGap build folder and even when i add it than? Files should be added to the project like cdv-plugin-fb-connect.js

and facebook-js-sdk.js

, so I can include them in index.html, but none of the files are added to the project. How can i do this?

+2


source to share


2 answers


See answer below for phonegap-build. Ignoring.

  • Add below to your config.xml file and make sure you put your config.xml file in the root folder with your index.html file:

    <gap:plugin name="com.phonegap.plugins.facebookconnect">
        <param name="APP_ID" value="..." />
        <param name="APP_NAME" value="..." />
    </gap:plugin>
    
          

  • Add below to <head></head>

    your index.html file and each .html file you want to access the plugin scripts:

    <script scr="phonegap.js"></script>
    <script src="cdv-plugin-fb-connect.js"></script > 
    <script src="facebook-js-sdk.js"></script > 
    
          

  • Read and follow the documentation located here . Be sure to pay attention to the paragraph under the heading "Facebook Requirements and Settings".

  • Once complete, upload your zipped project to build.phonegap.com and wait for your project to compile.



Notes:

  • You should only have 1 config.xml file in your project root directory.
  • Don't add phonegap.js, cdv-plugin-fb-connect.js, or facebook-js-sdk.js files to your project root. Phonegap Build will handle this for you.
+4


source


@Dom I did step by step as you pointed out: 1. added to config.xml file in platforms /android/assets/www/config.xml 2. included js files in header and when I execute phonegap install android

from cmd with this code:

document.addEventListener('deviceready', function() {
alert('1');
  FB.init({
      appId: 'appid',
      nativeInterface: CDV.FB,
      useCachedDialogs: false
  });
  alert('2');

  FB.getLoginStatus(handleStatusChange);
  alert('3');

  authUser();
  updateAuthElements();
  alert('4');
});

      



it only displays the first warning and removes the .js files from the heder. Why is this happening? - This was happening because when you edit in the phone call build you are not editing on platforms / adnroid / assets / www, but there is a www folder in the project root folder and you edit config.xml and index.html there and after running applications. built for android from there.

Edit: I just wrapped FB.init

in try / catch and I got this error: ReferenceError FB is not defined

I guess it's because js is not loading.

0


source







All Articles