I'm doing an app with React and facebook login is working in Chrome, Safari and others, but it isn't on Samsung Browser. I have tried to debug the code putting a breakpoint inside window.fbAsyncInit
But that function is never being executed on Samsung Browser (It does in other browsers). I have also checked that the script element #facebook-jssdk
is being added to the DOM. Meanwhile, the network tab of the dev-tools shows that there isn't any request to connect.facebook.net/es_ES/sdk.js
.
componentDidMount() {
if (!process.env.REACT_APP_FB_APP_ID) {
throw new Error(
'Facebook appId not found. Set the environment variable REACT_APP_FB_APP_ID with your appId'
);
}
if (!process.env.REACT_APP_GTM_ID) {
throw new Error(
'Google Tag Manager id not found. Set the environment variable REACT_APP_GTM_ID with your GTM id'
);
}
window.fbAsyncInit = () => {
console.log('init facebook init');
// $FlowFixMe
FB.init({
appId: process.env.REACT_APP_FB_APP_ID,
autoLogAppEvents: true,
xfbml: true,
version: 'v2.11'
});
window.FB.AppEvents.logEvent('started app');
};
(function(d, s, id) {
const element = d.getElementsByTagName(s)[0];
let fjs = element;
let js = element;
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = '//connect.facebook.net/es_ES/sdk.js';
// $FlowFixMe
fjs.parentNode.insertBefore(js, fjs);
})(document, 'script', 'facebook-jssdk');
}
I think it should be any kind of protection to XSS scripting or something like that, or maybe just the built-in Samsung adblock?. I tried to change js.src
protocols adding https:
and http:
but nothing seems to change.