需求概述
通過掃描二維碼下載APP已成為一個非常方便的通過掃描二維碼下載APP已成為一個大家常用且非常方便的方式,微信也成為掃描二維碼重要的工具,但是在我們推廣的過程中,經(jīng)常會碰到鏈接被微信攔截,用戶打開提示“已停止訪問該網(wǎng)頁”,從而無法下載app的問題。這是因為微信scheme接口會對含APK和IOS文件的鏈接進行攔截,所以用戶在微信中無法打開。
那么此時就需要微信內(nèi)可以直接下載app的功能了,下面給大家分享一下功能代碼和實現(xiàn)效果。
代碼處理教程:http://sk.go51w.cn/nt0013.html
功能實現(xiàn)后ios系統(tǒng)可在微信內(nèi)直接下載app,安卓則自動跳轉(zhuǎn)瀏覽器下載。
1. App Store應(yīng)用實現(xiàn)效果

2. 企業(yè)版app實現(xiàn)效果

3. 安卓用戶則自動打開手機瀏覽器下載app。
代碼編程
HTML代碼
var ua?= navigator.userAgent;
var isWeixin =??!!/MicroMessenger/i.test(ua);
CSS代碼
1 #weixin-tip{display:none;position:fixed;left:0;top:0;background:rgba(0,0,0,0.8);filter:alpha(opacity=80);width:100%;height:100%;z-index:100;}
2 #weixin-tip p{text-align:center;margin-top:10%;padding:0 5%;position:relative;}
3 #weixin-tip .close{color:#fff;padding:5px;font:bold 20px/24px simsun;text-shadow:0 1px 0 #ddd;position:absolute;top:0;left:5%;}
JS封裝代碼
1 var is_weixin = (function(){return navigator.userAgent.toLowerCase().indexOf(‘micromessenger’) !== -1})();
2 window.onload = function() {
3 var winHeight = typeof window.innerHeight != ‘undefined’ ? window.innerHeight : document.documentElement.clientHeight; //兼容IOS,不需要的可以去掉
4 var btn = document.getElementById(‘J_weixin’);
5 var tip = document.getElementById(‘weixin-tip’);
6 var close = document.getElementById(‘close’);
7 if (is_weixin) {
8 btn.onclick = function(e) {
9 tip.style.height = winHeight + ‘px’; //兼容IOS彈窗整屏
10 tip.style.display = ‘block’;
11 return false;
12 }
13 close.onclick = function() {
14 tip.style.display = ‘none’;
15 }
16 }
17 }
完成功能后,我們就算是解決了微信攔截分享鏈接的阻礙了,我們就可以直接在微信內(nèi)分享下載鏈接和二維碼進行宣傳引流了。如此也能夠極大的提高自己的APP在微信中的推廣轉(zhuǎn)化率,充分利用微信的用戶群體來宣傳引流。