I'm trying to make facebook messenger checkbox work, I've added the following code to my html
window.fbAsyncInit = function() {
FB.init({
appId: "{{ fb_app_id }}",
xfbml: true,
version: "v2.6"
});
FB.Event.subscribe('messenger_checkbox', function(e) {
console.log("messenger_checkbox event");
console.log(e);
if (e.event == 'rendered') {
console.log("Plugin was rendered");
} else if (e.event == 'checkbox') {
var checkboxState = e.state;
console.log("Checkbox state: " + checkboxState);
} else if (e.event == 'not_you') {
console.log("User clicked 'not you'");
} else if (e.event == 'hidden') {
console.log("Plugin was hidden");
}
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
<div class="fb-messenger-checkbox"
origin="my.site.com"
page_id="{{ fb_page_id }}"
messenger_app_id="{{ fb_app_id }}"
user_ref="{{ user_token }}"
prechecked="true"
allow_login="true"
size="xlarge"></div>
But whenever I refresh the page, the messenger checkbox doesn't show up, instead I get an error in chrome's console
Refused to display 'https://www.facebook.com/v2.6/plugins/messenger_checkbox.php?allow_login=tr…&user_ref=1tYPmZaYMKXKfcZiUtaENYTXH3H49OTP7tJrt5fyobCgepqziMA0Z037T5gto9o3'
in a frame because an ancestor violates the following Content Security Policy directive:
"frame-ancestors https://www.facebook.com".
Anyone might know how to fix this? Been stuck for the last 24hrs.
Edit: Docs states that i should add my domain as whitelist, i already did, but this error still persists.
origin
? – Essonite