以下代碼在Android中正常工作。但是,它不適用於IOS。IONIC 2 InAppBrowser在IOS中不工作
我們認爲browser.executeScript不在這裏工作。這裏我們從API獲取重定向url作爲html內容(this.paymentGatewayDetails),我們需要打開它。它在Android中正常工作。
嘗試在IOS 11.0手機中。
離子2.2版本
插件@離子本地/應用程序內瀏覽器「: 」^ 4.3.2「
這是我們正試圖執行函數
。
callGateway() {
return new Promise(
(resolve, reject) => {
let injected = false;
if (!this.paymentGatewayDetails) {
reject("PG_DET_INVALID")
}
const browser = this.iab.create("about:blank", "_blank", "location=no");
browser.show()
//inject html code to blank page. one time
browser.on("loadstop")
.subscribe(
(sucess) => {
if (!injected) {
browser.executeScript({ code: "document.write('" + this.paymentGatewayDetails + "');" }).then(
(sucess) => {
console.log("sucess");
browser.executeScript({ code: "document.mypg.submit();" }).then(
(sucess) => {
console.log("sucess redirection");
}, (err) => {
console.log("error redirection");
}
);
}, (err) => {
console.log("err")
}
);
injected = true;
}
console.log("success url is", sucess.url);
if (sucess.url.includes("mobile.mypg.com")) {
//payment gateway call sucess.
browser.close()
resolve("PG_CALL_SUCC")
}
}
)}
我們已經在plist文件給出
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
而且在INDEX.HTML>
<meta http-equiv="Content-Security-Policy" content="default-src gap://ready file://* *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline';」>
我們已經安裝了白名單插件也
科爾多瓦 - 插件白名單
Config.xml中加入這些線路也
<content src="index.html" />
<access origin="*" subdomains="true" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
科爾多瓦插件LS
com.darktalker.cordova.screenshot 0.1.5 「屏幕截圖」
cordova-plugin-actionsheet 2.3.3「ActionSheet」
科爾多瓦-插件-compat的1.1.0 「COMPAT」
科爾多瓦-插件控制檯1.0.5 「控制檯」
科爾多瓦-插件裝置1.1.4 「設備」
科爾多瓦-插件-dialogs 1.3.3 「通知」 是
科爾多瓦-插件-FCM 2.1.2 「FCMPlugin」
科爾多瓦-插件-地理位置2.4。3 「地理位置」
科爾多瓦-插件全球化1.0.7 「全球化」
科爾多瓦-插件熱線1.2.1 「熱線插件的PhoneGap」
科爾多瓦-插件-inappbrowser 1.7.1「 InAppBrowser 「
科爾多瓦 - 插件-MFP 8.0.2017072706 」IBM MobileFirst平臺 基金會「
科爾多瓦 - 插件-MFP-jsonstore 8.0.2017081712」 IBM MobileFirst平臺 Foundatio ñJSONStore 「
科爾多瓦 - 插件 - nativestorage 2.2.2 」NativeStorage「
科爾多瓦 - 插件 - okhttp 2.0.0 」OkHttp「
科爾多瓦 - 插件屏幕方位2.0.1」 屏幕方向「
科爾多瓦-插件-SMS 1.0.5 」SMS「
科爾多瓦-插件-濺射屏幕4.0.3 」啓動畫面「
科爾多瓦-插件-狀態欄2 .2.2 「狀態欄」
科爾多瓦-插件白名單1.3.1 「白名單」
科爾多瓦-插件-X-socialsharing 5.1.8 「SocialSharing」
cordova.plugins.diagnostic 3.6.6「診斷」
ES6-承諾,插件4.1.0 「無極」
離子-插件鍵盤2.2.1 「鍵盤」
uk.co.workingedge.phonegap.plugin.l aunchnavigator 4.0.4 「啓動 導航」
請幫助我們解決這個問題...
感謝
您可以編輯您的帖子,包括您的科爾多瓦插件。 '離子cordova插件ls' –