Detect if a webpage is loading into the embedded Facebook application on iOS / Android

I have a web application using the javascript SDK for Facebook. I want to determine if this web application works in my native Facebook application on iOS or Android. The reason is because if you are not working in the right browser, I want to open certain links in a floating iframe instead of a new webpage / tab.

How can I easily detect if it works on mobile devices in my native Facebook application. I know the answer that FB.UA suggests using, but this answer is 3 years old, and the API is no longer documented.

OR

Is it possible to specify HREF to launch a URL in a native browser on a mobile device? Then my links can launch the browser, and my web application continues to work in the native Facebook application.

+7
android ios facebook webview facebook-javascript-sdk
source share
1 answer

This works fine for me in JavaScript:

if (navigator.userAgent.match(/(iPod|iPhone|iPad)/) && navigator.userAgent.match(/FBAV/i)) { //iOS Facebook App Browser detected } 
+2
source share

All Articles