一张二维码分发APP的思路

来源:互联网 发布:超链接怎么调用js函数 编辑:程序博客网 时间:2024/04/29 17:27

0: 参考: http://www.baidufe.com/item/92457b4d0bfde1effa40.html

1: 创建一个网站如www.test.com,使用iis7来简单实现。

2: 写一个简单的html网页,用js于分发app,根据语言,渠道,或者平台等等.

3: 生成网站对应二维码。

4: 用户扫二维码后,直接访问你的www.test.com网站。js处理此次访问,更具不同平台渠道重定向app下载地址。

5: 简单的代码,实现安卓和ios平台分发。

<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>男生女生向前冲</title>
    <script type="text/javascript">
        // 获取终端的相关信息
        var Terminal = {
            // 辨别移动终端类型
            platform : function(){
                var u = navigator.userAgent, app = navigator.appVersion;
                return {
                    // android终端或者uc浏览器
                    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
                    // 是否为iPhone或者QQHD浏览器
                    iPhone: u.indexOf('iPhone') > -1 ,
                    // 是否iPad
                    iPad: u.indexOf('iPad') > -1 ,
                    // 是否是通过微信的扫一扫打开的
                    weChat: u.indexOf('MicroMessenger') > -1
                };
            }(),
        }

        var theUrl = 'http://www.baidu.com';
        if(Terminal.platform.android){
           theUrl = 'http://android-download';
        }

if(Terminal.platform.iPhone){
theUrl = 'http://ios-download';
}
        location.href = theUrl;


    </script>

</head>
<body>
</body>
</html>

 

0 0
原创粉丝点击