Cordova ios 应用程序在使用 stripe/v3 时自动重定向到 js.stripe.com
Cordova ios app automatically redirects to js.stripe.com when using stripe/v3
我正在尝试在我的 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-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
(在 cordova 应用程序 WebView 中)。
我看了其他类似的问题。我尝试添加到我的 config.xml:
<allow-navigation href="https://*.stripe.com/*" />
它没有解决将 WebView 重定向到网页的问题,但它现在将我带到另一个网页: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
这发生在我的主要项目和专门针对此错误的新黑色测试项目上。
测试项目有以下文件:
config.xml
<?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="dev@cordova.apache.org" 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>
页面不再重定向。
我通过将此添加到我的 config.xml
来修复此问题
<allow-navigation href="https://*.stripe.network/*" />
<allow-navigation href="https://*.stripe.com/*" />
allow-navigation
控制 WebView 本身可以导航到哪些 URL。仅适用于 top-level 个导航。
与allow-intent相比
控制允许应用请求系统打开哪些 URL。默认情况下,不允许外部 URL。
我正在尝试在我的 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-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 (在 cordova 应用程序 WebView 中)。
我看了其他类似的问题。我尝试添加到我的 config.xml:
<allow-navigation href="https://*.stripe.com/*" />
它没有解决将 WebView 重定向到网页的问题,但它现在将我带到另一个网页: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
这发生在我的主要项目和专门针对此错误的新黑色测试项目上。 测试项目有以下文件:
config.xml
<?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="dev@cordova.apache.org" 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>
页面不再重定向。
我通过将此添加到我的 config.xml
来修复此问题<allow-navigation href="https://*.stripe.network/*" />
<allow-navigation href="https://*.stripe.com/*" />
allow-navigation
控制 WebView 本身可以导航到哪些 URL。仅适用于 top-level 个导航。
与allow-intent相比
控制允许应用请求系统打开哪些 URL。默认情况下,不允许外部 URL。