I am trying to implement Facebook Messenger Checkbox Plugin into my AngularJS application. I am following this guide https://developers.facebook.com/docs/messenger-platform/plugin-reference/checkbox-plugin.
I managed to get it working. I navigate to the page and my messenger checkbox plugin is displayed, but when I navigate to another page and then get back to this page that contains Facebook Checkbox Messenger Plugin it is not rendered and I don't have anything logged from Facebook.
This is my init process for FB
$window.fbAsyncInit = function () {
FB.init({
appId: 'MY_FACEBOOK_APP_ID',
xfbml: true,
version: 'v2.8'
});
};
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
var fbElement = d.getElementById(id);
if (fbElement) {
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'));
and this is my directive for facebook messenger checkbox plugin
<div
class="fb-messenger-checkbox"
origin="{{origin}}"
page_id="{{pageId}}"
messenger_app_id="{{messengerAppId}}"
user_ref="{{userRef}}"
prechecked="true"
allow_login="true"
size="xlarge">
</div>
Like I said everything is ok when I navigate first time to the page (then Facebook Checkbox Messenger plugin is rendered). After that when I navigate to another page and get back the plugin is not displayed anymore. There are no any errors and also I do recalculate user_ref parameter every time to be a random string.
It seems to me that when one time FB.init is called after that when I navigate back to that page (even if I don't FB.init again) something is wrong.
Does anyone know what can be a problem?