mgcrea / cordova-facebook-connect

Cordova ARC plugin for the Facebook SDK
94 stars 43 forks source link

onLoad Issue / Question #17

Closed kittabit closed 11 years ago

kittabit commented 11 years ago

Hey,

First off, thanks for the ease of installation for this plugin! Was up and running super quickly!

Secondly, I have a quick (hopefully) question; is there any way to call the friends list on load? I'm using jQuery Mobile, but trying the following onload simply creates the issue shown after the code:

----Code---- $("#welcomePage").live('pageinit', function() { plugin.requestWithGraphPath(); });

----Error---- TypeError: window.plugins.facebookConnect is undefined

I've tried .click() with JS, tried creating new functions, etc and it all fails with the error above (or something very similar). If you click an tag with the function attached to it, everything works perfectly. Simply trying to avoid forcing the user to click a button.

Thanks for any help and I apologize if I'm just having a brain fart tonight. -Nick

mgcrea commented 11 years ago

You should wait for the phonegap "deviceready" event (ie. $(document).on("deviceready", function() {})) Before trying to use the plugins.

After what you will need to first perform a login & only after that you will be able to requestWithGraphPath. Check the examples.