Ionic 4-Inappbrowser无法在IOS中加载

问题描述 投票:0回答:1

我正在研究一个项目,我们需要从外部来源向移动应用程序获取JWT令牌。在Android中,它可以正常工作。但是在IOS中,我无法从Iframe获取令牌。

我已经使用了Ionic和Cordova的inappbrowsers,身份验证工作正常,并且能够在IOS的iframe中执行脚本,但是在executescript()函数中使用回调函数时,gap-iab://被内容阻止了安全政策。

[没有人在IOS中遇到过这样的问题并解决了。请告诉我。预先感谢。

我的代码:

const bro = this.iab.create(legacyUrl, '_blank', 'location=no,toolbar=no');
bro.on('loadstop').subscribe( (e) => {
                bro.executeScript({
                  code: 'if (document.getElementById("Token") != null) { document.getElementById("Token"). 
                         getAttribute("value");}'
                }).then((value) => {
                   console.log(value);
                });
});

并且我在IOS模拟器中运行时从应用程序中遇到以下错误,

Refused to load gap-iab://InAppBrowser627412330/%5Bnull%5D because it appears in neither the child-src directive nor the default-src directive of the Content Security Policy.
ios cordova ionic4 hybrid-mobile-app inappbrowser
1个回答
0
投票

“ gap-iab:”在您的内容安全策略中必须为child-src。通常在服务器端进行设置,并告诉您的应用内浏览器可以加载哪些内容以及从何处加载。

© www.soinside.com 2019 - 2024. All rights reserved.