How to detect Android in JavaScript?

As a web app owner, how can you detect when someone has re-published your app via UIWebView on iOS or a WebView in Android?

  • I have a very popular web app that I've discovered a number of people are re-publishing as Android and iOS apps without my permission.  Id like to present users with a link to our official apps.  Is there a way to use Javascript to probe the environment for an iOS UIWebView or for the Android WebView?  Or do these web views just look like a mobile browser?

  • Answer:

    Here is a list of three methods (Javascript, PHP, and .htaccess) to detect an Android browser so you can redirect to an “use our official app” type page: http://davidwalsh.name/detect-android Sadly you won’t be able to block competing iOS web apps using this method, but you can appeal to Apple for those.

Ben Reimers at Quora Visit the source

Was this solution helpful to you?

Other answers

Do you have your own iOS and Android apps?  If so, you can add a custom header to the page requests and have your server look for the header.  If the user agent is for iOS or Android but header doesn't exist serve up a "get our official iOS and Android apps" page. If you use a trademark in the custom header you may be able to sue anyone else that includes it.  Please also contact Apple and have them take down the counterfeit apps. Just curious:  Are these other people monetizing their apps?  If not, perhaps it would be best to provide limited functionality to let people try your product but let them know they can get the full version with the official app.  Then their apps become free marketing.

Pat Roberts

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.