需求分析
現(xiàn)在微信分享的功能很多,從分享的鏈接下載apk或者ios文件是很常用的一個(gè)功能堵泽。但是微信scheme接口會(huì)自動(dòng)屏蔽含apk或ios文件的下載鏈接,不允許直接通過(guò)微信下載安裝文件。導(dǎo)致分享的鏈接被微信攔截怨绣,用戶打開(kāi)提示“已停止訪問(wèn)該網(wǎng)頁(yè)”從而無(wú)法下載app。
那么此時(shí)我們就需要實(shí)現(xiàn)微信內(nèi)直接下載app的功能拷获,但很多人不知道如何實(shí)現(xiàn)篮撑,下面給大家講解功能的實(shí)現(xiàn)過(guò)程和實(shí)現(xiàn)效果。
實(shí)現(xiàn)教程:http://sk.go51w.cn/nt0012.html
功能實(shí)現(xiàn)后ios系統(tǒng)可在微信內(nèi)直接下載app匆瓜,安卓則自動(dòng)跳轉(zhuǎn)瀏覽器下載赢笨。
1. App Store應(yīng)用實(shí)現(xiàn)效果
2. 企業(yè)版app實(shí)現(xiàn)效果
3. 安卓用戶則自動(dòng)打開(kāi)手機(jī)瀏覽器下載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)分享下載鏈接和二維碼進(jìn)行宣傳引流了。如此也能夠極大的提高自己的APP在微信中的推廣轉(zhuǎn)化率桐筏,充分利用微信的用戶群體來(lái)宣傳引流怎憋。