cordova-khipu 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cordova-khipu",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Khipu Cordova Plugin",
|
|
5
|
+
"cordova": {
|
|
6
|
+
"id": "cordova-khipu",
|
|
7
|
+
"platforms": [
|
|
8
|
+
"android",
|
|
9
|
+
"ios"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/khipu/cordova-khipu.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"ecosystem:cordova",
|
|
18
|
+
"cordova-android",
|
|
19
|
+
"cordova-ios"
|
|
20
|
+
],
|
|
21
|
+
"author": "khipu",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/khipu/cordova-khipu/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/khipu/cordova-khipu#readme",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"release": "release-it"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@release-it/conventional-changelog": "^9.0.3",
|
|
32
|
+
"release-it": "^17.10.0",
|
|
33
|
+
"xml2js": "^0.6.2"
|
|
34
|
+
},
|
|
35
|
+
"release-it": {
|
|
36
|
+
"git": {
|
|
37
|
+
"requireCleanWorkingDir": true,
|
|
38
|
+
"commitMessage": "chore: release ${version}",
|
|
39
|
+
"tagName": "${version}",
|
|
40
|
+
"push": true,
|
|
41
|
+
"requireBranch": "main"
|
|
42
|
+
},
|
|
43
|
+
"npm": {
|
|
44
|
+
"publish": true
|
|
45
|
+
},
|
|
46
|
+
"github": {
|
|
47
|
+
"release": true
|
|
48
|
+
},
|
|
49
|
+
"plugins": {
|
|
50
|
+
"@release-it/conventional-changelog": {
|
|
51
|
+
"preset": "angular"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"hooks": {
|
|
55
|
+
"after:bump": "node scripts/update-plugin-version.js && git add plugin.xml && git commit -m 'chore: sync version to plugin.xml'"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
package/plugin.xml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2
|
+
<plugin id="cordova-khipu" version="1.0.2" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
<name>Cordova Khipu</name>
|
|
4
|
+
<js-module name="Khipu" src="www/cordova-khipu.js">
|
|
5
|
+
<clobbers target="window.Khipu"/>
|
|
6
|
+
</js-module>
|
|
7
|
+
<platform name="android">
|
|
8
|
+
<framework src="src/android/khipu.gradle" custom="true" type="gradleReference"/>
|
|
9
|
+
<config-file parent="/*" target="res/xml/config.xml">
|
|
10
|
+
<feature name="cordova-khipu">
|
|
11
|
+
<param name="android-package" value="com.khipu.cordova.KhipuPlugin"/>
|
|
12
|
+
</feature>
|
|
13
|
+
</config-file>
|
|
14
|
+
<config-file parent="/*" target="AndroidManifest.xml"/>
|
|
15
|
+
<source-file src="src/android/com/khipu/cordova/KhipuPlugin.java" target-dir="src/com/khipu/cordova"/>
|
|
16
|
+
</platform>
|
|
17
|
+
<platform name="ios">
|
|
18
|
+
<config-file parent="/*" target="config.xml">
|
|
19
|
+
<feature name="cordova-khipu">
|
|
20
|
+
<param name="ios-package" value="KhipuPlugin"/>
|
|
21
|
+
</feature>
|
|
22
|
+
</config-file>
|
|
23
|
+
<podspec>
|
|
24
|
+
<config>
|
|
25
|
+
<source url="https://github.com/CocoaPods/Specs.git"/>
|
|
26
|
+
</config>
|
|
27
|
+
<pods use-frameworks="true">
|
|
28
|
+
<pod name="KhipuClientIOS" version="2.7.7" swift-version="5.1"/>
|
|
29
|
+
</pods>
|
|
30
|
+
</podspec>
|
|
31
|
+
<source-file src="src/ios/KhipuPlugin.swift"/>
|
|
32
|
+
</platform>
|
|
33
|
+
<dependency id="cordova-plugin-add-swift-support" version="2.0.2"/>
|
|
34
|
+
</plugin>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const xml2js = require('xml2js');
|
|
4
|
+
|
|
5
|
+
// Rutas de los archivos
|
|
6
|
+
const packageJsonPath = path.resolve(__dirname, '../package.json');
|
|
7
|
+
const pluginXmlPath = path.resolve(__dirname, '../plugin.xml');
|
|
8
|
+
|
|
9
|
+
// Leer la versión de package.json
|
|
10
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
11
|
+
const newVersion = packageJson.version;
|
|
12
|
+
|
|
13
|
+
// Actualizar plugin.xml
|
|
14
|
+
fs.readFile(pluginXmlPath, 'utf-8', (err, data) => {
|
|
15
|
+
if (err) throw err;
|
|
16
|
+
|
|
17
|
+
xml2js.parseString(data, (err, result) => {
|
|
18
|
+
if (err) throw err;
|
|
19
|
+
|
|
20
|
+
// Actualizar la versión en plugin.xml
|
|
21
|
+
result.plugin.$.version = newVersion;
|
|
22
|
+
|
|
23
|
+
// Convertir de nuevo a XML
|
|
24
|
+
const builder = new xml2js.Builder();
|
|
25
|
+
const updatedXml = builder.buildObject(result);
|
|
26
|
+
|
|
27
|
+
// Guardar los cambios en plugin.xml
|
|
28
|
+
fs.writeFile(pluginXmlPath, updatedXml, 'utf-8', (err) => {
|
|
29
|
+
if (err) throw err;
|
|
30
|
+
console.log(`plugin.xml version updated to ${newVersion}`);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
package com.khipu.cordova;
|
|
2
|
+
|
|
3
|
+
import org.apache.cordova.CordovaPlugin;
|
|
4
|
+
import org.apache.cordova.CallbackContext;
|
|
5
|
+
|
|
6
|
+
import static com.khipu.client.KhipuKt.KHIPU_RESULT_EXTRA;
|
|
7
|
+
import static com.khipu.client.KhipuKt.getKhipuLauncherIntent;
|
|
8
|
+
|
|
9
|
+
import android.app.Activity;
|
|
10
|
+
import android.content.Intent;
|
|
11
|
+
|
|
12
|
+
import androidx.activity.result.ActivityResultLauncher;
|
|
13
|
+
import androidx.activity.result.contract.ActivityResultContracts;
|
|
14
|
+
|
|
15
|
+
import com.khipu.client.KhipuColors;
|
|
16
|
+
import com.khipu.client.KhipuOptions;
|
|
17
|
+
import com.khipu.client.KhipuResult;
|
|
18
|
+
|
|
19
|
+
import org.json.JSONArray;
|
|
20
|
+
import org.json.JSONException;
|
|
21
|
+
import org.json.JSONObject;
|
|
22
|
+
|
|
23
|
+
import java.util.Objects;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
public class KhipuPlugin extends CordovaPlugin {
|
|
27
|
+
|
|
28
|
+
private ActivityResultLauncher<Intent> launcher;
|
|
29
|
+
private CallbackContext callbackContext;
|
|
30
|
+
|
|
31
|
+
@Override
|
|
32
|
+
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
|
33
|
+
if ("startOperation".equals(action)) {
|
|
34
|
+
this.callbackContext = callbackContext;
|
|
35
|
+
JSONObject jsonObject = args.getJSONObject(0);
|
|
36
|
+
this.startOperation(jsonObject);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private void startOperation(JSONObject call) {
|
|
43
|
+
String operationId = call.optString("operationId");
|
|
44
|
+
if (operationId.isEmpty()) {
|
|
45
|
+
callbackContext.error("Must provide operationId");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
KhipuOptions.Builder optionsBuilder = new KhipuOptions.Builder();
|
|
49
|
+
JSONObject options = call.optJSONObject("options");
|
|
50
|
+
|
|
51
|
+
if (options != null) {
|
|
52
|
+
if (options.has("title")) {
|
|
53
|
+
optionsBuilder.topBarTitle(Objects.requireNonNull(options.optString("title")));
|
|
54
|
+
}
|
|
55
|
+
if (options.has("titleImageUrl")) {
|
|
56
|
+
optionsBuilder.topBarImageUrl(Objects.requireNonNull(options.optString("titleImageUrl")));
|
|
57
|
+
}
|
|
58
|
+
if (options.has("skipExitPage")) {
|
|
59
|
+
optionsBuilder.skipExitPage(Boolean.TRUE.equals(options.optBoolean("skipExitPage")));
|
|
60
|
+
}
|
|
61
|
+
if (options.has("showFooter")) {
|
|
62
|
+
optionsBuilder.showFooter(Boolean.TRUE.equals(options.optBoolean("showFooter")));
|
|
63
|
+
}
|
|
64
|
+
if (options.has("showMerchantLogo")) {
|
|
65
|
+
optionsBuilder.showMerchantLogo(Boolean.TRUE.equals(options.optBoolean("showMerchantLogo")));
|
|
66
|
+
}
|
|
67
|
+
if (options.has("showPaymentDetails")) {
|
|
68
|
+
optionsBuilder.showPaymentDetails(Boolean.TRUE.equals(options.optBoolean("showPaymentDetails")));
|
|
69
|
+
}
|
|
70
|
+
if (options.has("locale")) {
|
|
71
|
+
optionsBuilder.locale(Objects.requireNonNull(options.optString("locale")));
|
|
72
|
+
}
|
|
73
|
+
if (options.has("theme")) {
|
|
74
|
+
String theme = options.optString("theme");
|
|
75
|
+
switch (theme) {
|
|
76
|
+
case "light":
|
|
77
|
+
optionsBuilder.theme(KhipuOptions.Theme.LIGHT);
|
|
78
|
+
break;
|
|
79
|
+
case "dark":
|
|
80
|
+
optionsBuilder.theme(KhipuOptions.Theme.DARK);
|
|
81
|
+
break;
|
|
82
|
+
case "system":
|
|
83
|
+
optionsBuilder.theme(KhipuOptions.Theme.SYSTEM);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
KhipuColors.Builder colorsBuilder = new KhipuColors.Builder();
|
|
88
|
+
if (options.has("colors")) {
|
|
89
|
+
JSONObject colors = options.optJSONObject("colors");
|
|
90
|
+
if (colors != null) {
|
|
91
|
+
if (colors.has("lightBackground")) {
|
|
92
|
+
colorsBuilder.lightBackground(Objects.requireNonNull(colors.optString("lightBackground")));
|
|
93
|
+
}
|
|
94
|
+
if (colors.has("lightOnBackground")) {
|
|
95
|
+
colorsBuilder.lightOnBackground(Objects.requireNonNull(colors.optString("lightOnBackground")));
|
|
96
|
+
}
|
|
97
|
+
if (colors.has("lightPrimary")) {
|
|
98
|
+
colorsBuilder.lightPrimary(Objects.requireNonNull(colors.optString("lightPrimary")));
|
|
99
|
+
}
|
|
100
|
+
if (colors.has("lightOnPrimary")) {
|
|
101
|
+
colorsBuilder.lightOnPrimary(Objects.requireNonNull(colors.optString("lightOnPrimary")));
|
|
102
|
+
}
|
|
103
|
+
if (colors.has("lightTopBarContainer")) {
|
|
104
|
+
colorsBuilder.lightTopBarContainer(Objects.requireNonNull(colors.optString("lightTopBarContainer")));
|
|
105
|
+
}
|
|
106
|
+
if (colors.has("lightOnTopBarContainer")) {
|
|
107
|
+
colorsBuilder.lightOnTopBarContainer(Objects.requireNonNull(colors.optString("lightOnTopBarContainer")));
|
|
108
|
+
}
|
|
109
|
+
if (colors.has("darkBackground")) {
|
|
110
|
+
colorsBuilder.darkBackground(Objects.requireNonNull(colors.optString("darkBackground")));
|
|
111
|
+
}
|
|
112
|
+
if (colors.has("darkOnBackground")) {
|
|
113
|
+
colorsBuilder.darkOnBackground(Objects.requireNonNull(colors.optString("darkOnBackground")));
|
|
114
|
+
}
|
|
115
|
+
if (colors.has("darkPrimary")) {
|
|
116
|
+
colorsBuilder.darkPrimary(Objects.requireNonNull(colors.optString("darkPrimary")));
|
|
117
|
+
}
|
|
118
|
+
if (colors.has("darkOnPrimary")) {
|
|
119
|
+
colorsBuilder.darkOnPrimary(Objects.requireNonNull(colors.optString("darkOnPrimary")));
|
|
120
|
+
}
|
|
121
|
+
if (colors.has("darkTopBarContainer")) {
|
|
122
|
+
colorsBuilder.darkTopBarContainer(Objects.requireNonNull(colors.optString("darkTopBarContainer")));
|
|
123
|
+
}
|
|
124
|
+
if (colors.has("darkOnTopBarContainer")) {
|
|
125
|
+
colorsBuilder.darkOnTopBarContainer(Objects.requireNonNull(colors.optString("darkOnTopBarContainer")));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
optionsBuilder.colors(colorsBuilder.build());
|
|
130
|
+
}
|
|
131
|
+
cordova.getActivity().runOnUiThread(() -> launcher.launch(getKhipuLauncherIntent(cordova.getContext(), operationId, optionsBuilder.build())));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@Override
|
|
135
|
+
public void pluginInitialize() {
|
|
136
|
+
super.pluginInitialize();
|
|
137
|
+
launcher = cordova.getActivity().getActivityResultRegistry().register(
|
|
138
|
+
"cordova_khipu_plugin",
|
|
139
|
+
new ActivityResultContracts.StartActivityForResult(),
|
|
140
|
+
result -> {
|
|
141
|
+
if (result.getResultCode() == Activity.RESULT_OK) {
|
|
142
|
+
Intent data = result.getData();
|
|
143
|
+
if (data != null) {
|
|
144
|
+
KhipuResult khipuResult = (KhipuResult) Objects.requireNonNull(result.getData().getExtras()).getSerializable(KHIPU_RESULT_EXTRA);
|
|
145
|
+
assert khipuResult != null;
|
|
146
|
+
if ("ERROR".equals(khipuResult.getResult())) {
|
|
147
|
+
callbackContext.error(khipuResult.asJson());
|
|
148
|
+
} else {
|
|
149
|
+
callbackContext.success(khipuResult.asJson());
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
callbackContext.error("No data received");
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
callbackContext.error("Activity cancelled or failed");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
repositories{
|
|
2
|
+
google()
|
|
3
|
+
jcenter()
|
|
4
|
+
maven { url 'https://dev.khipu.com/nexus/content/repositories/khenshin' }
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
implementation 'com.khipu:khipu-client-android:2.7.6'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
android {
|
|
12
|
+
packagingOptions {
|
|
13
|
+
exclude 'META-INF/NOTICE'
|
|
14
|
+
exclude 'META-INF/LICENSE'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import KhipuClientIOS
|
|
2
|
+
|
|
3
|
+
@objc(KhipuPlugin)
|
|
4
|
+
public class KhipuPlugin: CDVPlugin {
|
|
5
|
+
|
|
6
|
+
@objc(startOperation:)
|
|
7
|
+
func startOperation(command: CDVInvokedUrlCommand) {
|
|
8
|
+
guard let call = command.arguments[0] as? [String: Any],
|
|
9
|
+
let operationId = call["operationId"] as? String, !call.isEmpty else {
|
|
10
|
+
handleError(command: command, message: "operationId must be provided and must be a string.")
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let options = getOptions(call: call)
|
|
15
|
+
|
|
16
|
+
startKhipuOperation(operationId: operationId, options: options) { result, error in
|
|
17
|
+
var pluginResult: CDVPluginResult
|
|
18
|
+
if let error = error {
|
|
19
|
+
pluginResult = CDVPluginResult(status: .error, messageAs: error)
|
|
20
|
+
} else if let result = result {
|
|
21
|
+
if (result["result"] as? String == "ERROR") {
|
|
22
|
+
pluginResult = CDVPluginResult(status: .error, messageAs: result)
|
|
23
|
+
} else {
|
|
24
|
+
pluginResult = CDVPluginResult(status: .ok, messageAs: result)
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
pluginResult = CDVPluginResult(status: .error, messageAs: "Unknown error")
|
|
28
|
+
}
|
|
29
|
+
self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func getOptions(call: [String: Any]) -> KhipuOptions {
|
|
34
|
+
var optionsBuilder = KhipuOptions.Builder()
|
|
35
|
+
|
|
36
|
+
let options = call["options"] as? [String: Any]
|
|
37
|
+
if(options != nil) {
|
|
38
|
+
if (options!["title"] != nil) {
|
|
39
|
+
optionsBuilder = optionsBuilder.topBarTitle(options!["title"]! as! String)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (options!["titleImageUrl"] != nil) {
|
|
43
|
+
optionsBuilder = optionsBuilder.topBarImageUrl(options!["titleImageUrl"]! as! String)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (options!["skipExitPage"] != nil) {
|
|
47
|
+
optionsBuilder = optionsBuilder.skipExitPage(options!["skipExitPage"]! as! Bool)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (options!["showFooter"] != nil) {
|
|
51
|
+
optionsBuilder = optionsBuilder.showFooter(options!["showFooter"]! as! Bool)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (options!["showMerchantLogo"] != nil) {
|
|
55
|
+
optionsBuilder = optionsBuilder.showMerchantLogo(options!["showMerchantLogo"]! as! Bool)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (options!["showPaymentDetails"] != nil) {
|
|
59
|
+
optionsBuilder = optionsBuilder.showPaymentDetails(options!["showPaymentDetails"]! as! Bool)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (options!["locale"] != nil) {
|
|
63
|
+
optionsBuilder = optionsBuilder.locale(options!["locale"]! as! String)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (options!["theme"] != nil) {
|
|
67
|
+
let theme = options!["theme"]! as! String
|
|
68
|
+
if(theme == "light") {
|
|
69
|
+
optionsBuilder = optionsBuilder.theme(.light)
|
|
70
|
+
} else if (theme == "dark") {
|
|
71
|
+
optionsBuilder = optionsBuilder.theme(.dark)
|
|
72
|
+
} else if (theme == "system") {
|
|
73
|
+
optionsBuilder = optionsBuilder.theme(.system)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (options!["colors"] != nil) {
|
|
78
|
+
let colors = options!["colors"]! as! [String: Any]
|
|
79
|
+
|
|
80
|
+
var colorsBuilder = KhipuColors.Builder()
|
|
81
|
+
|
|
82
|
+
if (colors["lightBackground"] != nil) {
|
|
83
|
+
colorsBuilder = colorsBuilder.lightBackground(colors["lightBackground"]! as! String)
|
|
84
|
+
}
|
|
85
|
+
if (colors["lightOnBackground"] != nil) {
|
|
86
|
+
colorsBuilder = colorsBuilder.lightOnBackground(colors["lightOnBackground"]! as! String)
|
|
87
|
+
}
|
|
88
|
+
if (colors["lightPrimary"] != nil) {
|
|
89
|
+
colorsBuilder = colorsBuilder.lightPrimary(colors["lightPrimary"]! as! String)
|
|
90
|
+
}
|
|
91
|
+
if (colors["lightOnPrimary"] != nil) {
|
|
92
|
+
colorsBuilder = colorsBuilder.lightOnPrimary(colors["lightOnPrimary"]! as! String)
|
|
93
|
+
}
|
|
94
|
+
if (colors["lightTopBarContainer"] != nil) {
|
|
95
|
+
colorsBuilder = colorsBuilder.lightTopBarContainer(colors["lightTopBarContainer"]! as! String)
|
|
96
|
+
}
|
|
97
|
+
if (colors["lightOnTopBarContainer"] != nil) {
|
|
98
|
+
colorsBuilder = colorsBuilder.lightOnTopBarContainer(colors["lightOnTopBarContainer"]! as! String)
|
|
99
|
+
}
|
|
100
|
+
if (colors["darkBackground"] != nil) {
|
|
101
|
+
colorsBuilder = colorsBuilder.darkBackground(colors["darkBackground"]! as! String)
|
|
102
|
+
}
|
|
103
|
+
if (colors["darkOnBackground"] != nil) {
|
|
104
|
+
colorsBuilder = colorsBuilder.darkOnBackground(colors["darkOnBackground"]! as! String)
|
|
105
|
+
}
|
|
106
|
+
if (colors["darkPrimary"] != nil) {
|
|
107
|
+
colorsBuilder = colorsBuilder.darkPrimary(colors["darkPrimary"]! as! String)
|
|
108
|
+
}
|
|
109
|
+
if (colors["darkOnPrimary"] != nil) {
|
|
110
|
+
colorsBuilder = colorsBuilder.darkOnPrimary(colors["darkOnPrimary"]! as! String)
|
|
111
|
+
}
|
|
112
|
+
if (colors["darkTopBarContainer"] != nil) {
|
|
113
|
+
colorsBuilder = colorsBuilder.darkTopBarContainer(colors["darkTopBarContainer"]! as! String)
|
|
114
|
+
}
|
|
115
|
+
if (colors["darkOnTopBarContainer"] != nil) {
|
|
116
|
+
colorsBuilder = colorsBuilder.darkOnTopBarContainer(colors["darkOnTopBarContainer"]! as! String)
|
|
117
|
+
}
|
|
118
|
+
optionsBuilder = optionsBuilder.colors(colorsBuilder.build())
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return optionsBuilder.build()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
func startKhipuOperation(operationId: String, options: KhipuOptions, completion: @escaping ([String: Any]?, String?) -> Void) {
|
|
127
|
+
DispatchQueue.main.async {
|
|
128
|
+
guard let presenter = UIApplication.shared.windows.filter({ $0.isKeyWindow }).first?.rootViewController else {
|
|
129
|
+
completion(nil, "No rootViewController found")
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
presenter.presentedViewController?.dismiss(animated: false)
|
|
133
|
+
|
|
134
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
|
135
|
+
KhipuLauncher.launch(presenter: presenter,
|
|
136
|
+
operationId: operationId,
|
|
137
|
+
options: options) { result in
|
|
138
|
+
completion([
|
|
139
|
+
"operationId": result.operationId,
|
|
140
|
+
"result": result.result,
|
|
141
|
+
"exitTitle": result.exitTitle,
|
|
142
|
+
"exitMessage": result.exitMessage,
|
|
143
|
+
"exitUrl": result.exitUrl as Any,
|
|
144
|
+
"failureReason": result.failureReason as Any,
|
|
145
|
+
"continueUrl": result.continueUrl as Any,
|
|
146
|
+
"events": result.events.map { event in
|
|
147
|
+
return [
|
|
148
|
+
"name": event.name,
|
|
149
|
+
"type": event.type,
|
|
150
|
+
"timestamp": event.timestamp
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
], nil)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
func handleError(command: CDVInvokedUrlCommand, message: String) {
|
|
160
|
+
let pluginResult = CDVPluginResult(status: .error, messageAs: message)
|
|
161
|
+
self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
|
|
162
|
+
}
|
|
163
|
+
}
|