About h5 Wake up app

I am waking up app with url scheme.
the requirement is that if app exists, open app, does not exist, ios jumps to appstore, Android jumps to google play.

var nowTime = new Date().valueOf();
     setTimeout(function() {
         var launchTime = new Date().valueOf() - nowTime;
         if (launchTime < 400) {
             if (checkIos()) {
                window.location.href = "https://itunes.apple.com/us/app/xxx/idxxx?mt=8";
             } else {
                window.location.href = "https://play.google.com/store/apps/details?id=xxx";
             }
        }
    }, 300);
    window.location.href = "url://url scheme";

but there is a bug. In safari, if app does not exist on the phone (it has not been downloaded yet), clicking the button will pop up a page that is not valid , followed by a pop-up of "whether to go to app store".

through Baidu, try to use iframe to request that url scheme, is ok in Android, but it doesn"t work in safari. It seems that iframe has been blocked in safari. Ask God if there is a good way to solve my problem. Thank you.

Menu