Don't use FB.Event.subscribe()
if you don't want to auto-login the user.
Instead, just create a normal button <button></button>
and on its click perform actions you want using FB.getLoginstatus()
and FB.login()
. So, on click of this button do this:
$( "#my_fb_button" ).click(function() {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
setField();
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
login();
} else {
// the user isn't logged in to Facebook.
login();
}
});
});
function login()
{
FB.login(function(response) {
if (response.authResponse) {
setField();
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'email,user_birthday'});
}
Hope the flow is clear now. Many apps use this flow too and it works like charm. Good luck!