【发布时间】:2020-02-05 19:36:07
【问题描述】:
我正在做一个项目,我们需要从外部源获取 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