Hello I’m creating a facebook page tab in which the owner of the facebook page will be able to sell anything.
So, when someone visits the page and click the checkout button the app calls the FB.login method and I get the following error.
Uncaught TypeError: Cannot read property 'postMessage' of null
at ha (sdk.js:95)
at Object.ba [as send] (sdk.js:95)
at i.<anonymous> (sdk.js:105)
at i.window.FB.i.enqueue (sdk.js:89)
at sa (sdk.js:105)
at i.<anonymous> (sdk.js:105)
at i.window.FB.i.enqueue (sdk.js:89)
at i.$JSONRPC4 (sdk.js:99)
at i.<anonymous> (sdk.js:98)
at la (sdk.js:142)
My code is here.
$('.login-checkout').on('click', function(event){
event.preventDefault();
checkLoginState('checkout');
});
function facebookLogin(action) {
FB.login(function(response) {
window.location = '/facebook?action=' + action + '&access_token=' + response.authResponse.accessToken;
}, {scope: 'public_profile,email'});
}
function checkLoginState(action) {
FB.getLoginStatus(function(response) {
if(response.status === 'connected') {
window.location = '/facebook?action=' + action + '&access_token=' + response.authResponse.accessToken;
} else {
facebookLogin(action);
}
});
}
The response.status of FB.getLoginStatus is not_authorized
.
I use the javascript SDK