3

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.

gabrielperales
  • 6,935
  • 1
  • 20
  • 19
  • Samsung Internet doesn't have a built-in ad-blocker (it has a tracking blocker you can enable by default in Secret Mode and extensions you can enable). Are there any JavaScript errors? (https://samsunginter.net/docs/remote-debugging) What version of Samsung Internet are you using? Is it possible to share a test case? – poshaughnessy Jan 13 '18 at 13:40
  • Hi @poshaughnessy, I'm using a Galaxy S8 with Samsung Internet 6.2.01.12, and there aren't JavaScript errors. Here is the test case https://masuno.co/login . Thank you – gabrielperales Jan 13 '18 at 13:46
  • 1
    I tried the test case and I got the same error as in Firefox (v57) on the desktop. Is this what you got too? Does it help narrow it down? https://drive.google.com/file/d/1ULX1TGElzDu8egyNBS8Q14jRcav-tybt/view?usp=sharing – poshaughnessy Jan 14 '18 at 16:00
  • @poshaughnessy yes, that is what I get. I didn't know it happened in Firefox too. – gabrielperales Jan 14 '18 at 16:32
  • 2
    Firefox blocks the JS SDK when tracking protection is enabled (which is the default AFAIK.) – CBroe Jan 15 '18 at 11:41
  • It seems different now, has the test case changed? Trying with the Tracking Blocker and/or a Content Blocker switched on (Samsung Internet v6.2), nothing happens when I press the 'Entra con Facebook' button. However, with the Tracking Blocker switched off and content blockers disabled, it proceeded to the "Log in with Facebook. Continue as [Name]" page OK. I proceeded and it took me back to the login page - I didn't see any errors. So I think you both correctly assumed the cause. I'm not sure what the solution should be, but I'll raise it with my colleagues. – poshaughnessy Jan 18 '18 at 16:15
  • p.s. Sorry my comment "Samsung Internet doesn't have a built-in ad-blocker" was probably confusing/inaccurate. I meant that it shouldn't have one _enabled_ by default (except in Secret Mode): https://medium.com/samsung-internet-dev/introducing-our-new-tracking-blocker-powered-by-disconnect-c00f118c1151 – poshaughnessy Jan 18 '18 at 16:18
  • @poshaughnessy we were deploying the backend just at that time, so maybe it could have interfered with the behaviour. I have also changed the deployment mode to production, so now is not giving those fullscreen errors, and now we are capturing errors sending them to sentry (maybe that's why you couldn't see errors) – gabrielperales Jan 18 '18 at 17:48

0 Answers0