admin管理员组文章数量:1531441
实现方式
页面控制
<div class="down-btn ios-btn" type='ios'></div>
<div class="down-btn and-btn" type='and'></div>
脚本控制
// 是否是微信
var isWx = navigator.userAgent.toLowerCase().indexOf('micromessenger') != -1;
// 下载按钮 点击
$(".down-btn").click(function(){
var type = $(this).attr('type'); // 获取类型
var ios_url = '应用在itunes上的地址';
var and_url = '安卓apk下载地址';;
var and_scheme = 'scheme://host/pathPrefix'; // 在应用约定的完整的 scheme
// 微信显示
if(isWx) {
return $(".tips").show(); // 提示层展示 微信端提示使用浏览器下载
}
// web 处理 ios
if(type === 'ios') {
return window.location.href = ios_url;
}
// web 处理 and
if(type === 'and') {
window.location.href = and_scheme; // 尝试唤起
t = Date.now(); // 设置当前时间
// 唤起失败则打开下载页
var timer = setTimeout(function() {
clearTimeout(timer);
// 1s 之后比较
// 原理:唤起 app 会让浏览器的定时器变慢
if (Date.now() - t < 1200) {
window.location.href = and_url; // 直接下载 app
}
}, 1000);
}
});
参考链接
- https://blog.csdn/m0_37678565/article/details/68491444
- https://blog.csdn/m0_37263637/article/details/78043664
- https://blog.csdn/gf771115/article/details/73177153
- https://blog.csdn/m0_37700275/article/details/81386910
版权声明:本文标题:微信公众号检测本地App, 安装则打开,未安装则下载的实现方式 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1725438568a1023273.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论