handleDownload() {
let ua = window.navigator.userAgent
if (!!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
// ios端
// 触发app启动
const appName = 'app的软件名,需要跟商店中参数一致'
window.location.href = `${ appName }://openApp`
// 设置一个延时,超过一定时间,页面跳转到商店app页面
setTimeout(() => {
window.location.href = 'app商店链接'
}, 2000)
} else if (ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1) {
// android端
window.location.href = 'app启动名,需要跟配置一致'
// 同ios一样,设置一个延时器
setTimeout(() => {
window.location.href = '安卓商店app链接'
}, 2000)
}
}
移动端浏览器中触发app打开/下载
最新推荐文章于 2022-03-15 18:03:41 发布