Advertisement
ZachCase

Cordova FacebookConnect Android Plugin Fix

Jun 13th, 2014
2,151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. Created Date: 06/13/2014 @ 4:26pm
  2. Updated Date: 06/13/2014 @ 4:26pm
  3. ____________________________________
  4. If you are having issues getting your app/project to compile after adding the FacebookConnect plug-in, or you are having the "Cordova Facebook Connect failed on init" error and you can't find a fix for it, follow this guide and see if it works for you. After 12+ hours of trying to troubleshoot I finally found a solution and I want to help anyone avoid the hell I just went through to get this app work.
  5.  
  6. ____________________________________
  7. Something to Consider Before Hand:
  8. ____________________________________
  9. What are you needing from this plug-in? Are you just wanting a user to log-in so you can grab personal info and you don't have any need to for dialog (FB.ui) calls? Then I highly recommend you do not use this plug-in at the moment. I love this plug-in and it is why I spent such an insane amount of my time trying to get it working, however, it is too unstable at the moment to deal with the hassle if you don't need everything it offers.
  10. - Instead I suggest you explore Christophe Coenraets' openFB. It is an OAuth solution to do just about everything FacebookConnect can. Only down side is, due to Facebook restricting what the Graph API can access, you can no longer post to a user's friend's wall. (Which is the main reason I couldn't use this option.)
  11. - openFB Website: http://coenraets.org/blog/2014/04/facebook-phonegap-cordova-without-plugin/
  12. - Christophe Coenraets' Twitter: @ccoenraets
  13.  
  14. ___________________________________
  15. Let's Get the Plug-In Working:
  16. ___________________________________
  17. 1) Install the lastest Cordova
  18. npm install -g cordova
  19.  
  20. 2) Create a new Cordova Project
  21. cordova create fbTest com.ddbuddyapp.fbTest "Facebook Connect"
  22.  
  23. 3) Change your dir to fbTest
  24. cd fbTest
  25.  
  26. 4) Download 0.4.0 version of Facebook Connect from GitHub and unzip. Remember where you unzip to.
  27. - https://github.com/phonegap/phonegap-facebook-plugin/releases/tag/0.4.0
  28.  
  29. 5) Install FacebookConnect version 0.4.0 to the Project. Make sure to add the APP_ID and APP_NAME variables.
  30. cordova plugin add C:/your/path/to/phonegap-facebook-plugin-0.4.0 --variable APP_ID="123456789123" --variable APP_NAME="Cool App"
  31.  
  32. 6) In your project folder go to the Facebook Connect plugin.xml in the plugins folder
  33. - plugins/com.phonegap.plugins.facebookconnect/plugin.xml
  34.  
  35. 7) Find the two lines that say <preference name="APP_ID" /> & <preference name="APP_NAME" />
  36. - Change <preference name="APP_ID" /> to <param name="APP_ID" value="123456789123"/>
  37. - Change <preference name="APP_NAME" /> to <param name="APP_NAME" value="Cool App"/>
  38.  
  39. 8) Go back to the Command Prompt and add the android platform
  40. cordova platform add android
  41. - Make sure the last line you see in the prompt after it finishes is "installing "com.phonegap.plugins.facebookconnect" for android
  42.  
  43. 9) Now lets take the index.html file from FacebookConnect's example "Simple" and paste it into our project folder's /www/ folder.
  44.  
  45. 10) Open up that index file
  46. -On line 19 change <script src="phongap.js"></script> to <script src="cordova.js"></script>
  47. -On line 148 put your appId for Facebook in for "appId"
  48. -FB.init({ appId: "123456789123", nativeInterface: CDV.FB, useCachedDialogs: false });
  49.  
  50. 11) All done! Let's build and run this bad boy.
  51. cordova build android
  52. cordova run android
  53.  
  54. Hopefully this worked for all of you, if you have any issues let me know at @ZBCase
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement