A have problems blocking pop-ups that appear on the Facebook JS SDK. After reading the documentation, I understand that the JS SDK call should be after the user clicks. This code works correctly, and the browser does not block the popup:
function Login() { FB.login(function (response) { if (response.authResponse) { DoSmth(response.authResponse.accessToken); } }, { scope:'user_birthday, publish_stream' }); }
But if I use this code anywhere (for example, on the wall, get user data), a pop-up window will be displayed in all cases, even if the user has already registered with facebook. I think this is not normal.
To determine that the user is already logged in, I use this code:
function CheckOrLogin() { FB.getLoginStatus(function (response) { if (response.status === 'connected') { DoSmth(response.authResponse.accessToken); } else { FB.login(function (response) { if (response.authResponse) { DoSmth(response.authResponse.accessToken); } }, { scope:'user_birthday, publish_stream' }); } }, true); }
In this case, the pop-up window will not be displayed if the user is already logged in. But if the user was not logged into facebook, this condition (if (response.status ===) returns false. And the browser will be BLOCK , which will be shown by FB.login. Is there any way to prevent this?
source share