IOS

1.url scheme

This scheme is basically for other browsers other than wechat, QQ built-in browser, QQ browser, etc., ask for a scheme from the native side, and then put it in a tag or location.href

A page hop made with an iframe, which triggers a timer to jump to the download address if the evoke scheme does not. But this way in ios, you get two prompts when you don’t have an app,

 var openApp = function (src) {
        // If the iframe is used to open the APP, it will switch to the APP directly and automatically block the default behavior of the A TAB
        // Otherwise open the href link of the a tag
        const ifr = document.createElement('iframe');
        ifr.src = src;
        ifr.style.display = 'none';
        document.body.appendChild(ifr);
        var poenTime = +new Date(a)window.setTimeout(() = > {
          document.body.removeChild(ifr);
          if ((+new Date()-openTime>2500)) {window.location = 'Where to download from the APP Store'}},600);
      };

Copy the code
2.Universal Link (ios)

This is an iOS9 feature that, if your APP supports Universal Links, makes it easy to launch your APP via traditional HTTP Links(no extra judgment required if your APP is already installed on an iOS device), Or open a web page (your app is not installed on an iOS device). It might be simpler to say that before iOS9, for the need to wake up an APP from a variety of browsers, Safari, UIWebView, or WKWebView, we usually had to use Scheme.

window.location.href ="Universal Link from APP"
Copy the code
conclusion

Compatible with writing

If (isGreaterThan9){window.location.href ="APP to Universal Link"; return; } openApp(src)Copy the code

android

Methods the similar

 if (openApp('url scheme url')) {
            openApp('url scheme url');
          } else {
            setTimeout(() = > {
              window.location.href = 'APP Market Download Address ';// It's usually Google, but it varies from store to store
            }, 600); }}Copy the code