Search code examples
facebook-javascript-sdkmobile-browser

Facebook like/share button on mobile browsers


I have used Facebooks Javacript SDK to add a sharebutton and a like button on my website, but it only works on a desktop computer browsers, not on mobile browsers..

For example I added the parts provided by FB:

<div id="fb-root"></div>
<script>(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 = 'https://connect.facebook.net/sv_SE/sdk.js#xfbml=1&version=v3.1';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="https://kanzan.se/interviews?id=" data-layout="button" data-action="like" data-size="small" data-show-faces="true" data-share="false"></div>

and the button shows up on my computer (even using chrome responsive design mode with mobile sizes.), but not when I use my phone (any phone) to access it. There the button is gone!

Have Facebook made it impossible to show like buttons on mobiles?


Solution

  • The problem is that I was in development mode all the time! This should be emphasized more clearly on different sites describing how "simple" it is to add a Facebook like button. I didn't even recognize it while making my Facebook account a development account.. only recently, when thinking about it I came to the conclusion that the problem has to do with the app id and all that comes with that.