How to detect Facebook in-app browser?

Have you had any experience in Facebook in-app browser detection? What's the core difference in user agent?

I don't want to know if it is a only mobile/ios/chrome. I need to know whether user agent is specific from Facebook in-app browser

Answers


You can check for FBAN / FBAV in the user agent.

Check this link: Facebook user agent

Sample code as @sascha suggested

function isFacebookApp() {
    var ua = navigator.userAgent || navigator.vendor || window.opera;
    return (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1);
}

To complete worker11811's answer on using the user agent, here's a code snippet to make it work:

function isFacebookApp() {
    var ua = navigator.userAgent || navigator.vendor || window.opera;
    return (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1);
}

this javascript works well

var standalone = window.navigator.standalone,
    userAgent = window.navigator.userAgent.toLowerCase(),
    safari = /safari/.test( userAgent ),
    ios = /iphone|ipod|ipad/.test( userAgent );

if( ios ) {
    if ( !standalone && safari ) {
        //browser
    } else if ( standalone && !safari ) {
        //standalone
    } else if ( !standalone && !safari ) {
        //uiwebview (Facebook in-app browser)

    };
} else {
    //not iOS
};

Need Your Help

Does Apache 2 gzip json output by default?

php apache gzip

I'm using this PHP code for json output. Does apache gzip it by default? Or, how can I check to make sure?

Swift: UISearchBar: Get text when search button clicked

ios swift cocoa-touch uikit uisearchbar

I'm playing around with Swift to learn it and right now I'm having trouble getting the text from a UISearchBar