admin管理员组

文章数量:1535124

一, 场景:

使用微信扫码或点击链接下载APK包时, 无法打开,且页面没有任何引导提示

二, 解决方案:

1,  php方式

在链接地址入口判断是否为微信内置浏览器访问 (是: 出现引导页, 否: 继续下载即可;)

php代码:

    public function downloadOp() {
        //判断是否是微信内置浏览器打开
        $ua = $_SERVER['HTTP_USER_AGENT'];
        if (strpos($ua, 'MicroMessenger') == false && strpos($ua, 'Windows Phone') == false) {
            //下载apk包
            $filename = 'android_app.apk'; 
            if (!load(APP_PATH . $filename)) {
                return '下载失败';
            }
        } else {
            //进入微信引导页
            return $this->fetch('yindao');
        }
    } 

yidao.html代码: 

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>提示</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta name="format-detection" content="telephone=no" />
    <meta content="false" name="twcClient" id="twcClient" />
    <style>
        body,
        html {
            width: 100%;
            height: 100%
        }

        * {
            margin: 0;
            padding: 0
        }

        body {
            background-color: rgba(0,0,0,0.6); 
            filter:alpha(opacity=80);
        }

        .top-bar-guidance {
            font-size: 15px;
            color: #fff;
            height: 40%;
            line-height: 1.8;
            padding-left: 30px;
            padding-top: 20px;
        }
    </style>
</head>

<body>
    <div class="top-bar-guidance">
        <p style="text-align: center; padding:0 5%;">
            <img src="/img/yindao.png" style="max-width: 100%; height: auto;" alt="微信打开"  />
        </p>
    </div>
</body>

</html>

注: 已测试,兼容andior和ios手机版.

2, html方式

其实就是把php的判断放到js代码中,即可

 

三, 效果展示

 

 

本文标签: 自定义浏览器链接微信扫码apk