Skip to content

Instantly share code, notes, and snippets.

@Angelfirenze
Forked from BobNisco/config.xml
Created February 5, 2014 22:44
Show Gist options
  • Save Angelfirenze/8834867 to your computer and use it in GitHub Desktop.
Save Angelfirenze/8834867 to your computer and use it in GitHub Desktop.
cordova plugin add https://github.com/phonegap/phonegap-facebook-plugin.git --variable APP_ID="YOUR_FB_APP_ID" --variable APP_NAME="YOUR_APP_NAME"
<script type="text/javascript">
if (typeof CDV == 'undefined') alert('CDV variable does not exist. Check that you have included cdv-plugin-fb-connect.js correctly');
if (typeof FB == 'undefined') alert('FB variable does not exist. Check that you have included the Facebook JS SDK file.');
document.addEventListener('deviceready', function() {
try {
FB.init({
appId: "YOUR_FB_APP_ID",
nativeInterface: CDV.FB,
useCachedDialogs: false
});
document.getElementById('data').innerHTML = "";
} catch (e) {
alert(e);
}
}, false);
</script>
var loginButton = $('#login-with-facebook');
loginButton.on('click', function(e) {
e.preventDefault();
FB.login(function(response) {
if (response.status === 'connected') {
alert('logged in');
} else {
alert('not logged in');
}
},{ scope: "email" });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment