Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug on Facebook Internal Browser (Mobile)?

Tags:

facebook

I'm developing website with a lot of HTML5 and CSS3 features. I'm also using iframe to embed several content on my website. It works fine if I open it using Chrome/Firefox/Safari mobile browser. However, if I share on facebook (post/page) and I opened it up with Facebook application with Facebook Internal Browser, my website is messed up.

Is there any tools or way to debug on Facebook Browser? Thanks.

like image 580
Eldwin Eldwin Avatar asked Nov 29 '14 06:11

Eldwin Eldwin


People also ask

How do I debug Facebook on my browser?

You can now remote-debug sites in the Facebook in-app browser on Android. It is enabled automatically so once your device is in dev mode with USB debugging and a browser open just visit chrome://inspect to attach to the WebView.

How do I open developer tools on Facebook?

You can access the Developer Settings panel by going to the Apps panel or developers.facebook.com/docs, hovering over your profile image in the upper right corner, and selecting Developer Settings from the dropdown menu.


2 Answers

This is how you can do the debugging yourself. It's painful, but the only way I've come across so far.

tl;dr Get the Facebook App loading a page on your local server so you can iterate quickly. Then print debug statements directly to the page until you figure out what is going on.

  1. Get a link to a page on your local server that you can access on your mobile device (test in mobile safari that it works). See this to find out your local IP address How do you access a website running on localhost from iPhone browser. It will look something like this http://192.xxx.1.127:3000/facebook-test

  2. Post that link on your Facebook page (you can make it private so your friends aren't all like WTF?)

  3. Click the posted link in the Facebook mobile App and it will open up in Facebook's mobile browser

  4. Since you don't have a console, you basically need to print debug statements directly to the page so it is visible. Put debug statements all over your code. If your problems are primarily related to CSS, then you can iteratively comment out stuff until you've found the issue(s) or print the relevant CSS attributes using JavaScript. Eg something like (using JQuery)

    function debug(str){$('body').append("<br>"+str);}

  5. Quite possibly the most painful part. The Facebook browser caches very aggressively. If you are making changes and nothing has happened, it's because the content is cached. You can sometimes resolve this by updating the URLs, eg /facebook-test-1, /facebook-test-2, or adding dummy parameters eg /facebook-test?dummy=1. But if the changes are in external css or js sheets it sometimes will still cache. To 100% clear the cache, delete the Facebook App from your mobile device and reinstall.

like image 184
AllTheCodez Avatar answered Oct 22 '22 08:10

AllTheCodez


The internal browser the Facebook app uses is essentially a uiWebView. Paul Irish has made a simple iOS app that lets you load any URL into a uiWebView which you then can debug using Safari's Developer Tools.

https://github.com/paulirish/iOS-WebView-App

like image 45
Simen Brekken Avatar answered Oct 22 '22 07:10

Simen Brekken