-1

I have an android app that can be accessed through a web browser too. I need to put a banner to let the user install the android application. How can i tell (if the user enters to the application through the web browser) using javascript or jquery, if the android app is already installed on his mobile phone? All i want to do is: If the user clics the banner and the app is already installed, open the android app. Otherwise, redirect the user to the playstore to let him install the app.

Marcos
  • 73
  • 1
  • 7

2 Answers2

0

Let's say your app is uploaded on both Apple AppStore and Google Play stores.

You need to:

  • Sniff in your webpage which OS is installed from the device accessing your page
    • good link to find how => here
  • Enable deep linking to listen for exactly same link from your mobile native app
    • for Android you need to register your main activity or any other activity to listen for these links
    • for iOS - no idea honestly, look around or find a 3rd party service
  • code for Google Play with deep link. And the deep link is same as your website page you want to cache/index in Google Search (or any other search engine)

    sample link to index/use => http://my_website.com/results

    // below snipplet need to be for Android devices only
    // i.e. need to sniff and have if/else validation for Android, iOS, desktop and so on
    // will call with 25 mills delay in case deep link fails, i.e. no installed app
    setTimeout(function () { window.location = "https://play.google.com/details?id=com.foo.myapp"; }, 25);
    
    // try to load the deep link URL
    window.location = "http://my_website.com/results";
    
  • repeat above for iOS and desktop/Windows Mobile

Additional advantage of above is the full app indexing without the lame App Indexing excuse from Google (min sdk no more than 17, Chrome for Android availability and so forth limitations).

Community
  • 1
  • 1
Dimitar Genov
  • 1,982
  • 10
  • 11
0

There is no way to detect if an app is installed using Javascript.

However you can get the behavior you describe and you don't even need any javascript:

  • Choose an URL for your app on a web server you own and make the banner link to it.
  • Set this web URL as a deep link handled by your app by specifing it in your app's manifest. It should open the main Activity.
  • On your web server, configure this URL to redirect to the Play Store URL of your app. Optional: if your app is also on iOS, you could detect the iOS browser and display something else.

If the app is installed it will handle the URL and open, otherwise the browser will follow the link and the redirect and the Play Store app will open to handle the Play Store URL to your app.

BladeCoder
  • 11,697
  • 2
  • 51
  • 46