I already found a way to detect if the page has been loaded inside of the Facebook app, which is done this way:
var ua = navigator.userAgent || navigator.vendor || window.opera;
if((ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1)) {
var openInBrowser = window.confirm("This page works best outside of the Facebook app. Do you want to open it in your browser instead?");
if (openInBrowser) {
window.open(
window.location.href,
'_blank'
);
}
}
However, this script does not seem to work. Is it because the phone blocks it (pop-up blocker)? The objective is to ask the user to load the page through the browser instead, if the user agrees, then open the page in Safari, Chrome or whatever is the preferred browser.