Open or download app from web

window.location.href = "myscheme://myhost:8080/index"; 
window.setTimeout(function(){
    window.location.href = "https://xxxx/apk/app.apk";
},2000);

the above is Baidu"s method, which can indeed open app, but wait a few seconds after the opening prompt is displayed, and the download prompt will appear, which does not meet the requirements. So I want to ask the following questions

.

solution 1: how can I turn off the timer when prompted to open app, and directly prompt to download app without running the timer when there is no app installed?

solution 2: take bilibili (bilibili"s official website) as an example. In bilibili"s mobile version, when bilibili app is installed on the phone, the button on web says, "Open app"; without app, the button on web shows" download app",. How can this effect be achieved?

Jul.10,2022

for this reason, I specifically put down a bilibili, but there is no change on my mobile phone chrome. I still "download APP".

it is true that the web side cannot detect whether it is installed on the current device. At present, the general method is what you are talking about, first try to open it, and then delay the download. That's what we use. Other developers are also working on delaying downloads, because if the device does install app, the browser will be placed in the background after app is called, and the timer will stop or be delayed.

for example, some use page visibility to identify, if the browser is not visible, indicating that app is called, then clear the timer;
method 2: when downloading after delay, instead of directly downloading app, you first jump to an intermediate page, which has a button that can be clicked to download, that is, the user experience will be better;


take a look at this https://juejin.im/entry/5a2e3...


Portal: from-a-web-page-on-an-iphone" rel=" nofollow noreferrer "> stackoverflow: How to check if an app is installed from a web-page on an iPhone?

in addition, you can refer to the practice of "Zhihu": do not customize Scheme, but directly use http (s), and then define the rules for Activity to intercept URL in the AndroidManifest.xml of App. If the browser finds that the redirected URL conforms to the above rules, it will call App.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7af244-277ff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7af244-277ff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?