Stripe在wkwebview中打开一个浏览器页面加载脚本

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

由于苹果的要求,我们正在将我们的 APP 转移到新的 wkweview。

其中一个应用程序正在使用 StripeJS sdk 以允许在应用程序中付款。当 APP 正在引导时出现问题,并且 stripe 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 标签或动态创建一个脚本标签并将其附加到正文:但没有人解决这个问题。

脚本包含测试

[Angular $http 方法]

$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/>)。

有谁知道为什么打开浏览器页面时包含该脚本?

ios ionic-framework stripe-payments wkwebview cordova-ios
1个回答
1
投票

我们发现了问题

问题是关于 cordova 配置不允许导航 url 的权限(文件“config.xml”)。更具体地说,我们需要在配置中添加以下行。文件

<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。

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