参考
https://blog.csdn.net/zy1281539626/article/details/79203853
https://blog.csdn.net/x550392236/article/details/77648985
https://www.jianshu.com/p/45af72036e58
还是不知道如何解析参数
在AndroidManifest.xml 文件的 的添加下面6行
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="zyt" android:host="app" android:pathPrefix="/openwith"/>
</intent-filter>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="apple-itunes-app" content="app-id=477927812" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<a id="openApp">点击打开US100 </a>
<p id="mod_pop" style="display:none;">请在其他浏览器中打开</p>
<script type="text/javascript">
window.onload = function() {
function isWeixin() {
var ua = navigator.userAgent.toLowerCase(); //获取判断用的对象
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true; //微信打开
} else {
return false; //不是微信打开
}
}
document.getElementById("openApp").onclick = function(e) {
if (isWeixin()) {
var modPop = document.getElementById("mod_pop");
modPop.style.display = "block";
} else {
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
//ios判断
window.location.href = "com.ncuos.usapp100://"; //通过app打开协议来打开app
window.setTimeout(function() {
window.location.href =
"https://itunes.apple.com/cn/app/id477927812"; //没有弹框打开app则打开app下载地址
}, 20);
} else if (/(Android)/i.test(navigator.userAgent)) {
//Android判断
var state = null;
try {
state = window.open("usapp://");
} catch (e) {}
if (state) {
//window.close();
} else {
window.location.href =
"https://www.baidu.com";
}
}
}
};
};
</script>
</body>
</html>