| 应用商店 | scheme |
| 小米 | mimarket://details?id=com.xx.xx |
| 三星 | samsungapps://ProductDetail/com.xx.xx |
| 华为 | appmarket://details?id=com.xx.xx |
| OPPO | oppomarket://details?packagename=com.xx.xx |
| vivo | vivomarket://details?id=com.xx.xx |
示例
const installApp = () => {
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
var loadDateTime = new Date()
window.location = 'https://xxxxxxx' //schema链接或者universal link
window.setTimeout(function () {
//如果没有安装app,便会执行setTimeout跳转下载页
var timeOutDateTime = new Date()
if (timeOutDateTime - loadDateTime < 5000) {
window.location = 'https://xxxxxxx' //ios下载页面
} else {
window.close()
}
}, 500)
} else if (navigator.userAgent.match(/android/i)) {
var state = null
try {
window.location = 'usp:xxxxx' //schema链接或者universal link
window.setTimeout(function () {
window.location = 'https:xxxxxxx' //android下载页面
}, 500)
} catch (e) { }
}
}
// 点击下载地址,有上架手机商店的直接打开应用商店,没有上架商店打开下载地址
const download = () => {
var u = navigator.userAgent
if (u.indexOf('iPhone') > -1) {
//苹果手机
window.location.href = 'https:xxxxxx' //ios下载地址
} else {
if (u.match(/(vivo|VIVO);?/i)) {
window.location.href = "vivomarket://details?id=com.xxxxx" // vivo手机 com.xxxx包名
} else if (u.match(/(OPPO|oppo);?/i)) {
window.location.href = "oppomarket://details?packagename=com.xxxxxx" // oppo手机
} else if (u.match(/(HUAWEI|HONOR);?/i)) {
window.location.href = "appmarket://details?id=com.xxxxx" // 华为手机
} else {
//安卓其他设备
window.location.href = 'https:xxxxxxx' // 下载地址
}
}
}微信浏览器
以上的应用商店地址,在浏览器可以唤起,但在微信浏览器中点击无效,目前看起来,多数是放应用宝的链接,打开应用宝下载,如果有应用宝,会进入应用宝网页,点击下载跳转到应用宝下载,如果没有应用宝,需要先下载应用宝。
https://sj.qq.com/appdetail/com.xx.xx
第三方库
https://github.com/suanmei/callapp-lib
案例
可以参考这个下载页https://www.36linkr.com/page/browser/articleShare?articleId=49fceaf44a99f8a54da7aff3f4401ad5