Detect from Browser If a Specific Application Is Installed in Android

Detect from browser if a specific application is installed in Android

You mean from JavaScript running in the browser? I think (hope) that's impossible. I wouldn't want any random website to be able to see what apps are installed.

If you want the user to install a particular app, you can provide a Market link on your website: http://developer.android.com/guide/publishing/publishing.html#marketintent

Edit: After your clarification in the comments to my answer, a more useful answer appeared below, which rightfully has more upvotes.

Detect if Android app has been installed on the device using a mobile web page - PHP and JS

Fortunately, this is not possible, for obvious privacy reasons.

The closest that you can do is in the application, have an activity that has an <intent-filter> for some URL structure, and have a link in the mobile Web site to a matching URL.

If the user clicks the link and the app is installed, the activity will be a chooser option for the user.

If the user clicks the link and the app is not installed, or they choose to stick with their Web browser from the chooser, whatever Web page exists at that URL will be displayed (E.g., instructions of how to download the app).

Is there a way to detect if a specific app is installed on (Android\iOS) device from Javascript?

Following a few hours of research + consulting with top experts I came to the conclusion that there is no legitimate way of achieving the goal of detecting whether a specific app is installed on the device without having the browser re-direct to the app if it is installed.

In iOS for example, there was an app just removed from the App Store because of violating the rules: SysSecInfo. The app managed to pull list of all running processes for example.

From: https://www.sektioneins.de/en/blog/16-05-09-system-and-security-info.html

See https://developer.apple.com/videos/play/wwdc2015/703/ "App
Detection" starting at 08:34

During this talk they discuss several APIs used to gather information
about processes currently running on your system (around 12:12 in the
video) and claimed to have fixed them. However as so often Apple has
only partially fixed the problems they claim to have fixed. Therefore
they have actually never stopped malicious applications from gathering
information about what other applications run currently on your
device, but only removed access to detail information that is only
relevant for harmless system information tools anyway.

System and Security Info is therefore still able to show the list of
running processes and enriches this list with information from the
codesigning information including the list of entitlements running
processes have.

Detect from browser if specific application is installed

If you want to detect with javascript inside the browser, you can probably use the collection "navigator.plugins". It works with Firefox, Opera and Chrome but unfortunately not with IE.

Update:
In FF, Opera and Chrome you can test it easily like this:

if (navigator.plugins["Adobe Acrobat"]) {
// do some stuff if it is installed
} else {
// do some other stuff if its not installed
}

Update #2:
If it is an ActiveX object in IE you can test if it exists by using something like this:

function getActiveXObject(name){
try{
return new ActiveXObject(name);
}
catch(err){
return undefined;
}
};

Another approach for IE is something similar to what JohnFx suggested (I found it here and have not tested it):

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Internet
Settings\User Agent\Post Platform

Detect an application is installed or not?

From Android How-to's

If you ever need to know if a particular app is installed on the user's device, you can use the PackageManager. From a Context class (e.g. an Activity or a Service) you can call getPackageManager(). This gives you a variety of methods, one of which is getPackageInfo(). Below is a method you might use. You might call it like this:

isAppInstalled("com.simexusa.campusmaps_full");

private boolean isAppInstalled(String packageName) {
PackageManager pm = getPackageManager();
boolean installed = false;
try {
pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
installed = true;
} catch (PackageManager.NameNotFoundException e) {
installed = false;
}
return installed;
}

Check if app is installed from webpage

To be honest, this is kind of a pain to implement on your own. There is no easy way to handle everything without a ton of nasty edge cases, most notably the 'Cannot Open Page" error users will see if they don't have your app installed. Until iOS 9, a reasonable basic implementation was putting a JavaScript redirect like this into a dedicated redirect page on your site:

setTimeout(function() {
window.location = "https://yourdomain.com";
}, 25);

// If "yourapp://" is registered, the user will see a dialog
// asking if they want to open your app. If they agree, your
// app will launch immediately and the timer won't fire.
// If not installed, you'll get an ugly "Cannot Open Page"
// dialogue and your fallback page will open when the timer expires.

window.location = "yourapp://";

Unfortunately this would still show a 'Cannot Open Page' error, but until recently it was possible to get around this in a reasonably user-friendly way by using a more nuanced version of this script. Sadly, Apple intentionally broke that with the iOS 9.2 update, so custom URL schemes are actually pretty much useless for deep linking now, unless you are certain the app is already installed on that device.

Apple is obviously trying to push the newer Universal Links standard as much as possible. Universal Links lets you use a normal http:// URL to a page on your website (the page could be a simple redirection to your desired fallback webpage without the custom URL trigger that causes the 'Cannot Open Page' error), which is intercepted by your phone and sent directly into your app if installed.

This is quite a lot to handle, so the best option might be a free service like Branch.io (full disclosure: I work with the team) to take care of all the technical aspects. You can find examples of apps using the Branch service here.

Open app if installed, otherwise open in google play store. (Javascript)

Simple answer: Deeplinks on android are handled by system level intents, so you can add an intent filter on your android app, and a corresponding server implementation for a given url. Then your JS just tries to open one URL, and the android system will handle the rest.

A more complete answer is here:

Detect from browser if a specific application is installed in Android

Note that the "answer" to that question is not where the info is - its in the most upvoted response though.



Related Topics



Leave a reply



Submit