admin管理员组

文章数量:1022736

I want to add .phonegap.plugins.facebookconnect to my PhoneGap build android app but I unable to do it. In doc site they say to add

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

in config.xml file but there is 3 config.xml files in PhoneGap build folder and even when I add it what than? There should be files added to project like cdv-plugin-fb-connect.js and facebook-js-sdk.js so I can include them in index.html but none of files are added to project. How can I manage that?

I want to add .phonegap.plugins.facebookconnect to my PhoneGap build android app but I unable to do it. In doc site they say to add

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

in config.xml file but there is 3 config.xml files in PhoneGap build folder and even when I add it what than? There should be files added to project like cdv-plugin-fb-connect.js and facebook-js-sdk.js so I can include them in index.html but none of files are added to project. How can I manage that?

Share Improve this question edited Sep 24, 2013 at 13:08 Dom 2,5691 gold badge19 silver badges28 bronze badges asked Sep 23, 2013 at 17:50 Dusan MalicDusan Malic 2314 silver badges15 bronze badges 3
  • Did you finally find a solution to the above problem? – alphacentauri Commented Apr 1, 2014 at 17:53
  • Yes, you have to use facebook plugin – Dusan Malic Commented Apr 2, 2014 at 21:17
  • Yes, you can check answer before yours... – Dusan Malic Commented May 11, 2014 at 9:40
Add a ment  | 

2 Answers 2

Reset to default 4

Answer below is for phonegap-build. Disregard.

  1. Add the below to your config.xml and ensure you place your config.xml in the root folder with your index.html file:

    <gap:plugin name=".phonegap.plugins.facebookconnect">
        <param name="APP_ID" value="..." />
        <param name="APP_NAME" value="..." />
    </gap:plugin>
    
  2. Add the below to the <head></head> of your index.html file and every .html file that 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 > 
    
  3. Read and follow the documentation located here. Be sure to pay attention to the paragraph titled "Facebook Requirements and Set-Up".

  4. Once plete, upload your zipped project to build.phonegap. and wait for your project to be piled.

Notes:

  • You should only have 1 config.xml file in the root of your project.
  • Do not add the phonegap.js, cdv-plugin-fb-connect.js file or facebook-js-sdk.js files to the root of your project. Phonegap Build will handle that for you.

@Dom I did step by step how you specified: 1. added to config.xml 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 first alert and removes .js files from heder. Why is that happening? - It was happening because when you edit in phonegap build you don't edit in platforms/adnroid/assets/www but in root folder of project there is www folder and you edit config.xml and index.html there and after running app it is build for android from there.

Edit: I have just wrapped FB.init in try/catch and I got this error : ReferenceError FB is not defined I think that is because js is not loading.

I want to add .phonegap.plugins.facebookconnect to my PhoneGap build android app but I unable to do it. In doc site they say to add

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

in config.xml file but there is 3 config.xml files in PhoneGap build folder and even when I add it what than? There should be files added to project like cdv-plugin-fb-connect.js and facebook-js-sdk.js so I can include them in index.html but none of files are added to project. How can I manage that?

I want to add .phonegap.plugins.facebookconnect to my PhoneGap build android app but I unable to do it. In doc site they say to add

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

in config.xml file but there is 3 config.xml files in PhoneGap build folder and even when I add it what than? There should be files added to project like cdv-plugin-fb-connect.js and facebook-js-sdk.js so I can include them in index.html but none of files are added to project. How can I manage that?

Share Improve this question edited Sep 24, 2013 at 13:08 Dom 2,5691 gold badge19 silver badges28 bronze badges asked Sep 23, 2013 at 17:50 Dusan MalicDusan Malic 2314 silver badges15 bronze badges 3
  • Did you finally find a solution to the above problem? – alphacentauri Commented Apr 1, 2014 at 17:53
  • Yes, you have to use facebook plugin – Dusan Malic Commented Apr 2, 2014 at 21:17
  • Yes, you can check answer before yours... – Dusan Malic Commented May 11, 2014 at 9:40
Add a ment  | 

2 Answers 2

Reset to default 4

Answer below is for phonegap-build. Disregard.

  1. Add the below to your config.xml and ensure you place your config.xml in the root folder with your index.html file:

    <gap:plugin name=".phonegap.plugins.facebookconnect">
        <param name="APP_ID" value="..." />
        <param name="APP_NAME" value="..." />
    </gap:plugin>
    
  2. Add the below to the <head></head> of your index.html file and every .html file that 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 > 
    
  3. Read and follow the documentation located here. Be sure to pay attention to the paragraph titled "Facebook Requirements and Set-Up".

  4. Once plete, upload your zipped project to build.phonegap. and wait for your project to be piled.

Notes:

  • You should only have 1 config.xml file in the root of your project.
  • Do not add the phonegap.js, cdv-plugin-fb-connect.js file or facebook-js-sdk.js files to the root of your project. Phonegap Build will handle that for you.

@Dom I did step by step how you specified: 1. added to config.xml 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 first alert and removes .js files from heder. Why is that happening? - It was happening because when you edit in phonegap build you don't edit in platforms/adnroid/assets/www but in root folder of project there is www folder and you edit config.xml and index.html there and after running app it is build for android from there.

Edit: I have just wrapped FB.init in try/catch and I got this error : ReferenceError FB is not defined I think that is because js is not loading.

本文标签: javascriptPhoneGap add Facebook Connect pluginStack Overflow