how to check app is installed or not in android using JavaScript | Check if android app is installed from web page browser

To avoid this or to avoid connect your app to some url you can do another trick to implement this using PHP and JS.

  1. You must create an intent-filter on your app’s main activity like this:
<intent-filter android:label="filter_react_native">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="MyCustomScheme" android:host="MyCustomHost" />
</intent-filter>
  1. Create PHP file redirect_to_app.php which will work in case user have the app installed.
<?php
header('Location: MyCustomScheme://MyCustomHost');
  1. Create HTML/PHP file check_redirect_to_app.php which must be shown for users which didn’t install your app yet.
...
<a href="https://play.google.com/store/apps/details?id=YOUR_APP_PACKAGE_NAME">Please install the application</a>
...

<script>
    location.href = '...redirect_to_app.php';
</script>
  1. Redirect users to check_redirect_to_app.phpcheck_redirect_to_app.php will try to redirect to MyCustomScheme://MyCustomHost automatically. In case it will not find such a app, it will coninue to show check_redirect_to_app.php content.


Leave a Reply