I am using PhoneGap 2.0 for iOS and trying to get FB JS SDK working. I’m loading the SDK asyncronously using the follow params:
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxx', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
....
I have a Facebook app tied to “localhost”. When I test the page using the XCode simulator or when opening up my index.html page in a browser (Firefox, Chrome, etc) from my filesystem, I get:
“An error occurred with [APPNAME]. Please try again later.”
If I hit the same file through a local apache instance (localhost:8080/index.html) it works just fine.
I noticed that the URL of the FB popup passes along your domain in the querystring. On localhost:8080, it passes “domain=localhost”. But in Xcode and from the filesystem it passes “domain=” and gives the above error each time.
Is there a correct way to either configure the FB app to work in a “domain-less” context, or would you setup the FB.init in a different manner?
Take a look at the Facebook Connect Plugin:
https://github.com/davejohnson/phonegap-plugin-facebook-connect
(Check the branch, cordova-2.0-facebook-ios-3.0, if using with the Facebook SDK 3.0 for iOS)
See if that is what you’re looking for. The plugin needs to be updated for the just released Facebook SDK 3.1, but should nonetheless be functional. Only issue is if you’re running on iOS6 it will not auth against the native iOS6 credentials without a few changes. It will auth by fast app-switching to FB iOS app or FB web app.