问题描述
由于苹果的需求,我们正在将我们的APP移至新的新wkweview。
其中一个应用程序正在使用StripeJS sdk,以便允许在应用程序中付款。当APP正在引导时,并且条带sdk包含以下代码时,会发生问题:
// Payment service is not initialized yet
$.ajax({
type: "GET",cache: true,url: "https://js.stripe.com/v3/",dataType: "script",error: function(XMLHttpRequest,textStatus,errorThrown) {
Logger.error("An error ocurred during SDK download");
def.reject();
},success: function() {
Logger.debug("Stipe JDK downloaded correctly");
initialized = true;
def.resolve();
}
});
我们已经尝试在index.html中使用''head标签或动态创建一个脚本TAG并将其附加到正文:但是没有人解决此问题。
脚本包含测试
[Angular $ http method]
$http({
method: "GET",url: "https://js.stripe.com/v3/"
}).then(
function(res) {
angular.element("body").append("<script>" + res.data + "</script>");
},function(err) {
def.reject();
});
[index.html]
<html>
<head>
<script type="text/javascript" src="https://js.stripe.com/v3/"></script>
...
问题
打开浏览器页面,APP留在后台;更具体地说,“ METRICS_CONTROLLER”的情况是在第767行的切换中捕获的(请参见url https://js.stripe.com/v3/>的库)。
解决方法
为回答我的问题,我们发现了问题。
问题与cordova配置(文件'config.xml')不允许的浏览URL权限有关。 更具体地说,我们需要在配置中添加以下行。文件
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
最后,我们的CORS权限定义为:
<access origin="*" />
<allow-intent href="sms:*" />
<allow-intent href="tel:*" />
<allow-intent href="geo:*" />
<allow-intent href="mailto:*" />
<allow-intent href="file://*/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
'*'是因为APP可以触发外部资源,所以我们无法知道用户将在APP中打开哪个url。
希望这项帮助@saperlipopette 西蒙