用于deeplink的js方法(判断手机是否安装app)
代码功能:
判断手机/平板是否安装app
如果安装 则调用app的scheme,传入url当作参数,来做后续操作
如果没有安装 则跳转到app store/google play 下载app
代码如下:
(function() { var openUrl = window.location.search; try{ openUrl = openUrl.substring(1,openUrl.length); }catch(e){ } var isiOS = navigator.userAgent.match('iPad') || navigator.userAgent.match('iPhone') || navigator.userAgent.match('iPod'), isAndroid = navigator.userAgent .match('Android'),isDesktop = !isiOS&&!isAndroid; if (isiOS) { setTimeout(function () { window.location = "itms-apps://itunes.apple.com/app/[name]/[id]?mt=8"; },25); window.location = "[scheme]://[host]?url="+openUrl; }else if(isAndroid){ window.location = "intent://[host]/"+"url="+openUrl+"#Intent;scheme=[scheme];package=[package_name];end"; }else{ window.location.href = openUrl; } })();
相关推荐
88274956 2020-11-03
runner 2020-09-01
梦的天空 2020-08-25
移动开发与培训 2020-08-16
ReunionIsland 2020-08-16
lyqdanang 2020-08-16
MyNameIsXiaoLai 2020-07-08
星辰的笔记 2020-07-04
csstpeixun 2020-06-28
letheashura 2020-06-26
liaoxuewu 2020-06-26
sunzhihaofuture 2020-06-21
FEvivi 2020-06-16
坚持着执着 2020-06-16
waterv 2020-06-14
xiaoge00 2020-06-14
firejq 2020-06-14
firstboy0 2020-06-14
e度空间 2020-06-12
zhongweinan 2020-06-10