Android and IOS's browsers detect whether a client is installed

  • 2020-06-03 08:12:20
  • OfStack

We want more users to use our products and we want to retain more users. This is when the meaning of letting users use the client becomes particularly important.

After all, the client actually occupies the user's desktop, and we see our products more or less every day.
Then, as the Web product on the mobile end, users visit our page through the mobile browser, and we hope that users can directly use or download our client product.
Finally there is the download Banner1 said.

IOS

Speaking of IOS, the exciting thing is that since IOS6, all we need to do is add the meta tag to html.
The specific meta label is: < meta name="apple-itunes-app" content="app-id=504274740" / >
For more details, of course, see Apple's developer platform documentation: Promoting Apps with Smart App Banners
How about below IOS6?
My answer is: show me one download banner.

Android

For Android, if we're careful, a lot of apps are running in the background. It doesn't even work.
In this way, we can determine whether our App is installed by sending a request to the background process and then determining whether the request responds correctly.
If the response is not correct, we assume that our client application is not installed.
The basic idea is to look at the code implementation:

(function() {
    var isInstalled,
        url = '_url_', //  Looking for a android Engineers want it. 
        script = document.createElement('script');
    script.src = url;
    script.onload = function() {
        // alert('Is installed.');
        isInstalled = true;
    };
    script.onerror = function() {
        // alert('May be not installed.');
        isInstalled = false;
    }
    document.body.appendChild(script);
})();


Related articles: