8

我有一个问题,我创建了一个有角度的 PWA,我的应用程序使用 auth0-lock 作为其身份验证,现在我的问题是......例如,当您单击 Google 等单一登录选项之一时,您会被退出PWA 和 safari,有什么办法可以防止这种情况发生吗?

我试过把这段代码放在我的 index.html

<!-- Prevent app from opening new safari page -->
<script type="text/javascript">
    (function(document,navigator,standalone) {
        // prevents links from apps from oppening in mobile safari
        // this javascript must be the first script in your <head>
        if ((standalone in navigator) && navigator[standalone]) {
            var curnode, location=document.location, stop=/^(a|html)$/i;
            document.addEventListener('click', function(e) {
                curnode=e.target;
                while (!(stop).test(curnode.nodeName)) {
                    curnode=curnode.parentNode;
                }
                // Condidions to do this only on links to your own app
                // if you want all links, use if('href' in curnode) instead.
                if('href' in curnode && ( curnode.href.indexOf('http') || ~curnode.href.indexOf(location.host) ) ) {
                    e.preventDefault();
                    location.href = curnode.href;
                }
            },false);
        }
    })(document,window.navigator,'standalone');
</script>

但这似乎不起作用,我已经看到了其他一些可以防止这种情况发生的 javascript hack,但我还没有找到一个可以在我的 Angular 应用程序中使用的方法?

有人对这个有经验么??

谢谢

4

1 回答 1

3

它不是 Angular 特有的,而是 PWA 特有的。Apple 根据新的PWA 清单规则改变了 iOS 11.3 中的行为。

这个问题是已知的,Apple 将致力于解决这个问题。

不幸的是,这意味着在 iOS 11.3 的 PWA 中没有什么可做的……</p>

于 2018-06-03T15:45:54.257 回答