Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

url scheme唤起app后还是打开了app下载链接怎么办?

let openApp = function () {
            var u = navigator.userAgent;
            var isWeixin = u.toLowerCase().indexOf('micromessenger') !== -1; // 微信内
            var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端
            var isIOS = !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/); //IOS终端
            // 微信内
            if (isBlackApp()) {
                alert('请在浏览器上打开')
            } else {
                //android端
                if (isAndroid) {
                    //安卓app的scheme协议
                    window.location.href = 'xxx://';
                    setTimeout(function () {
                        let hidden = window.document.hidden || window.document.mozHidden || window.document
                            .msHidden || window.document.webkitHidden
                        if (typeof hidden == "undefined" || hidden == false) {
                            //应用宝下载地址 (emmm 找不到淘宝应用宝的地址,这里放的是 lucky coffee 地址)
                            window.location.href =
                                "https://a.app.qq.com/o/simple.jsp?pkgname=com.lucky.luckyclient";
                        }
                    }, 2000);
                }
                //ios端
                if (isIOS) {
                    //ios的scheme协议
                    window.location.href = 'xxx://'
                    setTimeout(function () {
                        let hidden = window.document.hidden || window.document.mozHidden || window.document
                            .msHidden || window.document.webkitHidden
                        if (typeof hidden == "undefined" || hidden == false) {
                            //App store下载地址
                            window.location.href = "http://itunes.apple.com/app/id387682726";
                        }
                    }, 2000);
                }
            }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...