问题描述
我正在尝试在我的Cordova ios应用程序中实现条纹支付.我对我的android应用做了同样的事情,并且工作正常,但是使用ios,我立即被重定向到url "> https://js.stripe.com/v3/m-outer-7e4b9b871fee876475cf1d5d316fe456.html#url = file%3A%2F%2F%2FUsers%2Fpeter%2FLibrary%2FDeveloper%2FCoreSimulator%2FDevices%2F9D689B57-710A-44FF-A531-209A2F2F2%Funds%F2%F%F2%2F39452448-BC9C-48CC-A645-30216C5E780E%2FTestProject.app%2Fwww%2Findex.html& title = Hello%20World& referrer =& muid = NA& sid = NA& version = 6& preview = false (在cordova应用程序WebView中).
I am trying to implement stripe payments into my Cordova ios app. I did the same for my android app and it works fine but with ios I am immediately redirected to the url https://js.stripe.com/v3/m-outer-7e4b9b871fee876475cf1d5d316fe456.html#url=file%3A%2F%2F%2FUsers%2Fpeter%2FLibrary%2FDeveloper%2FCoreSimulator%2FDevices%2F9D689B57-710A-44FF-A531-209A40951971%2Fdata%2FContainers%2FBundle%2FApplication%2F39452448-BC9C-48CC-A645-30216C5E780E%2FTestProject.app%2Fwww%2Findex.html&title=Hello%20World&referrer=&muid=NA&sid=NA&version=6&preview=false(within the cordova app WebView).
我看了其他类似的问题.我尝试添加到我的config.xml中:
I had a look at the other similar questions. I tried adding to my config.xml:
<allow-navigation href="https://*.stripe.com/*" />
It did not fix the problem of redirecting the WebView to a web page but it now takes me to another web page: https://m.stripe.network/inner.html#url=file%3A%2F%2F%2FUsers%2Fpeter%2FLibrary%2FDeveloper%2FCoreSimulator%2FDevices%2F9D689B57-710A-44FF-A531-209A40951971%2Fdata%2FContainers%2FBundle%2FApplication%2F8F59C0AB-C0B4-47B8-BE59-ED7F4BA6E50D%2FTestProject.app%2Fwww%2Findex.html&title=Hello%20World&referrer=&muid=NA&sid=NA&version=6&preview=false
简称为stripe.network
which is shortened to just stripe.network
这既发生在我的主项目中,又发生在专门针对此错误的新的黑色测试项目中.测试项目具有以下文件:
This happened both on my main project and on a new black test project made specifically for this bug.The test project has the following files:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.menumeals.test" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>TestProject</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-navigation href="https://*.stripe.com/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
<meta name="color-scheme" content="light dark">
<link rel="stylesheet" href="css/index.css">
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
<a href="index2.html">Go to index2</a>
</div>
<script src="https://js.stripe.com/v3"></script>
<script src="cordova.js"></script>
<script src="js/index.js"></script>
</body>
</html>
index.js
var app = {
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
onDeviceReady: function() {
// Cordova is now initialized. Have fun!
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
document.getElementById('deviceready').classList.add('ready');
}
}
app.initialize();
当我拿出< script src ="https://js.stripe.com/v3"></script>
时,页面不再重定向.
When I take out the <script src="https://js.stripe.com/v3"></script>
the page no longer redirects.
推荐答案
我通过将其添加到config.xml中来解决了该问题
I fixed this by adding this to my config.xml
<allow-navigation href="https://*.stripe.network/*" />
<allow-navigation href="https://*.stripe.com/*" />
允许导航
控制WebView本身可以导航到的URL.仅适用于顶级导航.
allow-navigation
Controls which URLs the WebView itself can be navigated to. Applies to top-level navigations only.
控制允许该应用要求系统打开的URL.默认情况下,不允许使用外部URL.
Controls which URLs the app is allowed to ask the system to open. By default, no external URLs are allowed.
这篇关于使用Stripe/v3时,Cordova ios应用程序会自动重定向到js.stripe.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!