永发信息网

如何用js检测手机是否安装某个app

答案:2  悬赏:80  手机版
解决时间 2021-01-31 00:42
  • 提问者网友:暗中人
  • 2021-01-30 17:25
如何用js检测手机是否安装某个app
最佳答案
  • 五星知识达人网友:几近狂妄
  • 2021-01-30 17:40
1,判断是否安装某app
这个问题只能是APP才有可能做到,代码与网页端无关
2,JS调用Andorid/IOS的接口
这个问题需要两端配合,移动APP端书写调用接口及调用规则,JS按照语法调用即可
全部回答
  • 1楼网友:患得患失的劫
  • 2021-01-30 19:01
js检测app是否安装的情况 我们在浏览网页的时候,你会看到一个网页下面漂浮着一个提示框“打开app”或者“下载app的字样”,如果你的手机已经安装过这个app,那么网页会提示“打开app”,如果没有安装,那就会提示“下载app的字样” 这个从技术角度是如何去实现的呢?下面我给大家分享这块技术,去年公司给国际动漫节做项目的时候,客户就提到这个需求,在点击网页企业的时候 那么直接打开app(如果已经安装了) 如果没有安装过,直接打开app页面 下面我把这块的源码分享一下 if (navigator.useragent.match(/android/i)) { // 通过iframe的方式试图打开app,如果能正常打开,会直接切换到app,并自动阻止a标签的默认行为 // 否则打开a标签的href链接 var isinstalled; //下面是安卓端app接口调用的地址,自己根据情况去修改 var ifrsrc = 'cartooncomicsshowtwo://platformapi/startapp? type=0&id=${com.id}&phone_num=${com.phone_num}'; var ifr = document.createelement('iframe'); ifr.src = ifrsrc; ifr.style.display = 'none'; ifr.onload = function() { // alert('is installed.'); isinstalled = true; alert(isinstalled); document.getelementbyid('openapp0').click(); }; ifr.onerror = function() { // alert('may be not installed.'); isinstalled = false; alert(isinstalled); } document.body.appendchild(ifr); settimeout(function() { document.body.removechild(ifr); },1000); } //ios判断 if (navigator.useragent.match(/(iphone|ipod|ipad);?/i)) if (navigator.useragent.match(/(iphone|ipod|ipad);?/i)) { //animation://com.yz.animation var isinstalled; //var gz = '{comname:${com.short_name},comid:${com.id},comphonenum:${com.phone_num},type:0}'; //var jsongz =json.parse(gz); //下面是ios调用的地址,自己根据情况去修改 var ifrsrc = 'animation://?comname=${com.short_name}&comid=${com.id}&comphonenum=${com.phone_num}&type=0'; var ifr = document.createelement('iframe'); ifr.src = ifrsrc; ifr.style.display = 'none'; ifr.onload = function() { // alert('is installed.'); isinstalled = true; alert(isinstalled); document.getelementbyid('openapp1').click(); }; ifr.onerror = function() { // alert('may be not installed.'); isinstalled = false; alert(isinstalled); } document.body.appendchild(ifr); settimeout(function() { document.body.removechild(ifr); },1000); } }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯