idwise-cordova-sdk 4.6.0 → 5.0.0-alpha.0
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 +1 -1
- package/plugin.xml +5 -2
- package/readme.md +38 -0
- package/src/android/IDWiseCordovaSDK.kt +291 -67
- package/src/android/idwise-sdk.gradle +2 -1
- package/src/ios/IDWiseCordovaSDK.swift +289 -80
- package/www/IDWiseCordovaSDK.js +37 -35
- package/www/IDWiseDynamicCordovaSDK.js +130 -0
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="idwise-cordova-sdk" version="4.6.
|
|
2
|
+
<plugin id="idwise-cordova-sdk" version="4.6.9" xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
4
4
|
<name>IDWiseCordovaSDK</name>
|
|
5
5
|
<js-module name="IDWiseCordovaSDK" src="www/IDWiseCordovaSDK.js">
|
|
6
6
|
<clobbers target="IDWise" />
|
|
7
7
|
</js-module>
|
|
8
|
+
<js-module name="IDWiseCordovaSDK" src="www/IDWiseDynamicCordovaSDK.js">
|
|
9
|
+
<clobbers target="IDWiseDynamic" />
|
|
10
|
+
</js-module>
|
|
8
11
|
<platform name="ios">
|
|
9
12
|
<config-file parent="/*" target="config.xml">
|
|
10
13
|
<preference name="UseSwiftLanguageVersion" value="4.2" />
|
|
@@ -21,7 +24,7 @@
|
|
|
21
24
|
<source url="https://github.com/idwise/ios-sdk.git" />
|
|
22
25
|
</config>
|
|
23
26
|
<pods use-frameworks="true">
|
|
24
|
-
<pod name="IDWise" spec="
|
|
27
|
+
<pod name="IDWise" spec="5.0.0" />
|
|
25
28
|
</pods>
|
|
26
29
|
</podspec>
|
|
27
30
|
</platform>
|
package/readme.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img alt="idwise-Cordova-sdk" src="https://www.idwise.com/wp-content/uploads/2022/09/IDWise-Logo.svg" width="300">
|
|
3
|
+
</p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
Next-Gen Identity Verification Suite<br/>
|
|
6
|
+
<a href="https://www.idwise.com/">idwise.com</a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
[![Version][version-badge]][package]
|
|
12
|
+
|
|
13
|
+
<p align="center"><i>IDWise React Native SDK, a package having a bridge implementation which provides an ease with the integration of IDWise Native Android and iOS SDKs.</i></p>
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
|
+
Refer to the [getting started guide](https://docs.idwise.com/docs/integration-with-idwise) for instructions.
|
|
18
|
+
|
|
19
|
+
## Documentation
|
|
20
|
+
|
|
21
|
+
Check the sdk and their usage in our [documentation](https://docs.idwise.com/docs/idwise-cordova-sdk).
|
|
22
|
+
|
|
23
|
+
## Try it out
|
|
24
|
+
|
|
25
|
+
🧑💻 The source code for the examples are under the [/example](/example) folder.
|
|
26
|
+
|
|
27
|
+
📲 You can also try out components in our [demo app](https://github.com/idwise/idwise-react-native-sdk-samples) available in Github.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
cordova plugin add idwise-cordova-sdk
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
<!-- badges -->
|
|
36
|
+
|
|
37
|
+
[version-badge]: https://img.shields.io/npm/v/idwise-cordova-sdk.svg?style=flat-square
|
|
38
|
+
[package]: https://www.npmjs.com/package/idwise-cordova-sdk
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
package idwise_cordova_sdk;
|
|
2
2
|
|
|
3
3
|
import android.util.Log
|
|
4
|
+
import com.google.gson.Gson
|
|
5
|
+
import com.google.gson.reflect.TypeToken
|
|
4
6
|
import com.idwise.sdk.IDWise
|
|
5
|
-
import com.idwise.sdk.
|
|
6
|
-
import com.idwise.sdk.
|
|
7
|
-
import com.idwise.sdk.
|
|
8
|
-
import com.idwise.sdk.data.models
|
|
7
|
+
import com.idwise.sdk.IDWiseDynamic
|
|
8
|
+
import com.idwise.sdk.IDWiseSDKJourneyCallback
|
|
9
|
+
import com.idwise.sdk.IDWiseSDKStepCallback
|
|
10
|
+
import com.idwise.sdk.data.models.*
|
|
9
11
|
import org.apache.cordova.CallbackContext
|
|
10
12
|
import org.apache.cordova.CordovaPlugin
|
|
11
13
|
import org.apache.cordova.PluginResult
|
|
12
14
|
import org.json.JSONArray
|
|
13
15
|
import org.json.JSONException
|
|
14
16
|
import org.json.JSONObject
|
|
15
|
-
|
|
17
|
+
import java.io.ByteArrayOutputStream
|
|
18
|
+
import android.graphics.Bitmap
|
|
19
|
+
import android.util.Base64
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
22
|
* This class echoes a string called from JavaScript.
|
|
19
23
|
*/
|
|
20
24
|
class IDWiseCordovaSDK : CordovaPlugin() {
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
val gson = Gson()
|
|
28
|
+
lateinit var journeyCallbackContext: CallbackContext
|
|
29
|
+
|
|
21
30
|
@Throws(JSONException::class)
|
|
22
31
|
override fun execute(
|
|
23
32
|
action: String,
|
|
@@ -45,9 +54,68 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
45
54
|
val flowId = args.getString(0)
|
|
46
55
|
val referenceNumber = args.getString(1)
|
|
47
56
|
val locale = args.getString(2)
|
|
48
|
-
|
|
57
|
+
val applicantDetails = args.getString(3)
|
|
58
|
+
startJourney(flowId, referenceNumber, locale, applicantDetails, callbackContext)
|
|
59
|
+
return true
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
"startDynamicJourney" -> {
|
|
63
|
+
val flowId = args.getString(0)
|
|
64
|
+
val referenceNumber = args.getString(1)
|
|
65
|
+
val locale = args.getString(2)
|
|
66
|
+
val applicantDetails = args.getString(3)
|
|
67
|
+
startDynamicJourney(flowId, referenceNumber, locale, applicantDetails, callbackContext)
|
|
49
68
|
return true
|
|
50
69
|
}
|
|
70
|
+
|
|
71
|
+
"resumeJourney" -> {
|
|
72
|
+
val flowId = args.getString(0)
|
|
73
|
+
val journeyId = args.getString(1)
|
|
74
|
+
val locale = args.getString(2)
|
|
75
|
+
|
|
76
|
+
resumeJourney(flowId, journeyId, locale, callbackContext)
|
|
77
|
+
return true
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
"resumeDynamicJourney" -> {
|
|
82
|
+
val flowId = args.getString(0)
|
|
83
|
+
val journeyId = args.getString(1)
|
|
84
|
+
val locale = args.getString(2)
|
|
85
|
+
|
|
86
|
+
resumeDynamicJourney(flowId, journeyId, locale, callbackContext)
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
"getJourneySummary" -> {
|
|
91
|
+
getJourneySummary(callbackContext)
|
|
92
|
+
return true
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
"startStep" -> {
|
|
96
|
+
val stepId = args.getString(0)
|
|
97
|
+
startStep(stepId)
|
|
98
|
+
return true
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
"skipStep" -> {
|
|
102
|
+
val stepId = args.getString(0)
|
|
103
|
+
skipStep(stepId)
|
|
104
|
+
return true
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
"unloadSDK" -> {
|
|
108
|
+
unloadSDK()
|
|
109
|
+
return true
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
"finishJourney" -> {
|
|
113
|
+
finishJourney()
|
|
114
|
+
return true
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
51
119
|
}
|
|
52
120
|
return false
|
|
53
121
|
}
|
|
@@ -62,10 +130,7 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
62
130
|
val params = JSONObject()
|
|
63
131
|
params.put("event", "onError")
|
|
64
132
|
|
|
65
|
-
|
|
66
|
-
data.put("errorCode", error!!.errorCode)
|
|
67
|
-
data.put("message", error!!.message)
|
|
68
|
-
params.put("data", data)
|
|
133
|
+
params.put("data", gson.toJson(error!!))
|
|
69
134
|
|
|
70
135
|
val result = PluginResult(PluginResult.Status.ERROR, params)
|
|
71
136
|
result.keepCallback = true
|
|
@@ -73,92 +138,251 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
73
138
|
}
|
|
74
139
|
}
|
|
75
140
|
|
|
141
|
+
|
|
76
142
|
private fun startJourney(
|
|
77
143
|
flowId: String,
|
|
78
144
|
referenceNumber: String,
|
|
79
145
|
locale: String,
|
|
146
|
+
applicantDetails: String?,
|
|
80
147
|
callbackContext: CallbackContext
|
|
81
148
|
) {
|
|
149
|
+
journeyCallbackContext = callbackContext
|
|
150
|
+
|
|
151
|
+
val applicantDetailsObject: HashMap<String, String>? =
|
|
152
|
+
if (applicantDetails == null || applicantDetails == "null") null else Gson().fromJson(
|
|
153
|
+
gson.toJson(applicantDetails), object : TypeToken<HashMap<String, String>>() {}.type
|
|
154
|
+
)
|
|
155
|
+
|
|
82
156
|
IDWise.startJourney(
|
|
83
157
|
this.cordova.activity,
|
|
84
158
|
flowId,
|
|
85
159
|
referenceNumber,
|
|
86
160
|
locale,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
161
|
+
applicantDetailsObject,
|
|
162
|
+
journeyCallbacks
|
|
163
|
+
)
|
|
164
|
+
}
|
|
91
165
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
166
|
+
fun resumeJourney(
|
|
167
|
+
flowId: String,
|
|
168
|
+
journeyId: String,
|
|
169
|
+
locale: String? = null,
|
|
170
|
+
callbackContext: CallbackContext
|
|
171
|
+
) {
|
|
172
|
+
journeyCallbackContext = callbackContext
|
|
173
|
+
IDWise.resumeJourney(this.cordova.activity, flowId, journeyId, locale, journeyCallbacks)
|
|
174
|
+
}
|
|
95
175
|
|
|
96
|
-
|
|
97
|
-
|
|
176
|
+
fun resumeDynamicJourney(
|
|
177
|
+
flowId: String,
|
|
178
|
+
journeyId: String,
|
|
179
|
+
locale: String? = null,
|
|
180
|
+
callbackContext: CallbackContext
|
|
181
|
+
) {
|
|
182
|
+
journeyCallbackContext = callbackContext
|
|
183
|
+
IDWiseDynamic.resumeJourney(
|
|
184
|
+
this.cordova.activity,
|
|
185
|
+
flowId,
|
|
186
|
+
journeyId,
|
|
187
|
+
locale,
|
|
188
|
+
journeyCallbacks,
|
|
189
|
+
stepCallbacks
|
|
190
|
+
)
|
|
191
|
+
}
|
|
98
192
|
|
|
99
|
-
callbackContext.sendPluginResult(result)
|
|
100
|
-
}
|
|
101
193
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
194
|
+
private fun startDynamicJourney(
|
|
195
|
+
flowId: String,
|
|
196
|
+
referenceNumber: String,
|
|
197
|
+
locale: String,
|
|
198
|
+
applicantDetails: String?,
|
|
199
|
+
callbackContext: CallbackContext
|
|
200
|
+
) {
|
|
201
|
+
journeyCallbackContext = callbackContext
|
|
105
202
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
203
|
+
val applicantDetailsObject: HashMap<String, String>? =
|
|
204
|
+
if (applicantDetails == null || applicantDetails == "null") null else Gson().fromJson(
|
|
205
|
+
gson.toJson(applicantDetails), object : TypeToken<HashMap<String, String>>() {}.type
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
IDWiseDynamic.startJourney(
|
|
209
|
+
this.cordova.activity,
|
|
210
|
+
flowId,
|
|
211
|
+
referenceNumber,
|
|
212
|
+
locale,
|
|
213
|
+
applicantDetailsObject,
|
|
214
|
+
journeyCallbacks,
|
|
215
|
+
stepCallbacks
|
|
216
|
+
)
|
|
217
|
+
}
|
|
109
218
|
|
|
110
|
-
|
|
111
|
-
|
|
219
|
+
private fun startStep(stepId: String) {
|
|
220
|
+
IDWiseDynamic.startStep(
|
|
221
|
+
this.cordova.activity,
|
|
222
|
+
stepId
|
|
223
|
+
)
|
|
224
|
+
}
|
|
112
225
|
|
|
113
|
-
|
|
114
|
-
|
|
226
|
+
private fun skipStep(stepId: String) {
|
|
227
|
+
IDWiseDynamic.skipStep(stepId)
|
|
228
|
+
}
|
|
115
229
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
) {
|
|
120
|
-
val params = JSONObject()
|
|
121
|
-
params.put("event", "onJourneyCompleted")
|
|
230
|
+
private fun unloadSDK() {
|
|
231
|
+
IDWiseDynamic.unloadSDK()
|
|
232
|
+
}
|
|
122
233
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
234
|
+
private fun finishJourney() {
|
|
235
|
+
IDWiseDynamic.finishJourney()
|
|
236
|
+
}
|
|
126
237
|
|
|
127
|
-
|
|
128
|
-
|
|
238
|
+
private fun getJourneySummary(callbackContext: CallbackContext){
|
|
239
|
+
IDWiseDynamic.getJourneySummary { journeySummary, error ->
|
|
240
|
+
if (journeySummary != null) {
|
|
241
|
+
val params = JSONObject()
|
|
242
|
+
params.put("journeySummary", gson.toJson(journeySummary))
|
|
243
|
+
val result = PluginResult(PluginResult.Status.OK, params)
|
|
244
|
+
result.keepCallback = false
|
|
245
|
+
callbackContext.sendPluginResult(result)
|
|
246
|
+
} else if(error != null){
|
|
247
|
+
val params = JSONObject()
|
|
248
|
+
params.put("error", gson.toJson(error!!))
|
|
249
|
+
val result = PluginResult(PluginResult.Status.ERROR, params)
|
|
250
|
+
result.keepCallback = false
|
|
251
|
+
callbackContext.sendPluginResult(result)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
129
255
|
|
|
130
|
-
|
|
131
|
-
|
|
256
|
+
private val journeyCallbacks = object : IDWiseSDKJourneyCallback {
|
|
257
|
+
override fun onJourneyStarted(journeyInfo: JourneyStartedInfo) {
|
|
258
|
+
val params = JSONObject()
|
|
259
|
+
params.put("event", "onJourneyStarted")
|
|
132
260
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
261
|
+
params.put("data", gson.toJson(journeyInfo))
|
|
262
|
+
|
|
263
|
+
val result = PluginResult(PluginResult.Status.OK, params)
|
|
264
|
+
result.keepCallback = true
|
|
136
265
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
params.put("data", data)
|
|
266
|
+
journeyCallbackContext.sendPluginResult(result)
|
|
267
|
+
}
|
|
140
268
|
|
|
141
|
-
|
|
142
|
-
|
|
269
|
+
override fun onJourneyResumed(journeyInfo: JourneyResumedInfo) {
|
|
270
|
+
val params = JSONObject()
|
|
271
|
+
params.put("event", "onJourneyResumed")
|
|
272
|
+
params.put("data", gson.toJson(journeyInfo))
|
|
143
273
|
|
|
144
|
-
|
|
274
|
+
val result = PluginResult(PluginResult.Status.OK, params)
|
|
275
|
+
result.keepCallback = true
|
|
145
276
|
|
|
146
|
-
|
|
277
|
+
journeyCallbackContext.sendPluginResult(result)
|
|
278
|
+
}
|
|
147
279
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
280
|
+
override fun onJourneyCompleted(
|
|
281
|
+
journeyInfo: JourneyCompletedInfo
|
|
282
|
+
) {
|
|
283
|
+
val params = JSONObject()
|
|
284
|
+
params.put("event", "onJourneyCompleted")
|
|
151
285
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
286
|
+
params.put("data", gson.toJson(journeyInfo))
|
|
287
|
+
|
|
288
|
+
val result = PluginResult(PluginResult.Status.OK, params)
|
|
289
|
+
result.keepCallback = false
|
|
290
|
+
|
|
291
|
+
journeyCallbackContext.sendPluginResult(result)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
override fun onJourneyCancelled(journeyInfo: JourneyCancelledInfo) {
|
|
295
|
+
val params = JSONObject()
|
|
296
|
+
params.put("event", "onJourneyCancelled")
|
|
297
|
+
|
|
298
|
+
params.put("data", gson.toJson(journeyInfo))
|
|
299
|
+
|
|
300
|
+
val result = PluginResult(PluginResult.Status.OK, params)
|
|
301
|
+
result.keepCallback = false
|
|
302
|
+
|
|
303
|
+
journeyCallbackContext.sendPluginResult(result)
|
|
304
|
+
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
override fun onError(error: IDWiseSDKError) {
|
|
308
|
+
val params = JSONObject()
|
|
309
|
+
params.put("event", "onError")
|
|
310
|
+
params.put("data", gson.toJson(error))
|
|
311
|
+
|
|
312
|
+
val result = PluginResult(PluginResult.Status.ERROR, params)
|
|
313
|
+
result.keepCallback = true
|
|
314
|
+
journeyCallbackContext.sendPluginResult(result)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
private val stepCallbacks = object : IDWiseSDKStepCallback {
|
|
319
|
+
override fun onStepCaptured(stepCapturedInfo: StepCapturedInfo) {
|
|
320
|
+
Log.d("stepCallbacks", "onStepCaptured ${stepCapturedInfo.stepId}")
|
|
321
|
+
val params = JSONObject()
|
|
322
|
+
params.put("event", "onStepCaptured")
|
|
323
|
+
|
|
324
|
+
val originalImage = convertImageToBase64String(stepCapturedInfo.originalImage)
|
|
325
|
+
val croppedImage = convertImageToBase64String(stepCapturedInfo.croppedImage)
|
|
326
|
+
|
|
327
|
+
val resp = JSONObject()
|
|
328
|
+
resp.put("stepId", stepCapturedInfo.stepId)
|
|
329
|
+
resp.put("croppedImage",croppedImage)
|
|
330
|
+
resp.put("originalImage", originalImage)
|
|
331
|
+
|
|
332
|
+
params.put("data", gson.toJson(resp))
|
|
333
|
+
|
|
334
|
+
Log.d("stepCallbacks", "onStepCaptured ${params}")
|
|
335
|
+
val result = PluginResult(PluginResult.Status.OK, params)
|
|
336
|
+
result.keepCallback = true
|
|
337
|
+
|
|
338
|
+
journeyCallbackContext.sendPluginResult(result)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
override fun onStepResult(stepResultInfo: StepResultInfo) {
|
|
342
|
+
Log.d("stepCallbacks", "onStepResult ${stepResultInfo.stepId}")
|
|
343
|
+
val params = JSONObject()
|
|
344
|
+
params.put("event", "onStepResult")
|
|
345
|
+
params.put("data",gson.toJson(stepResultInfo))
|
|
346
|
+
|
|
347
|
+
val result = PluginResult(PluginResult.Status.OK, params)
|
|
348
|
+
result.keepCallback = true
|
|
349
|
+
|
|
350
|
+
journeyCallbackContext.sendPluginResult(result)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
override fun onStepCancelled(stepCancelledInfo: StepCancelledInfo) {
|
|
354
|
+
Log.d("stepCallbacks", "onStepCancelled Step ${stepCancelledInfo.stepId} cancelled!!")
|
|
355
|
+
val params = JSONObject()
|
|
356
|
+
params.put("event", "onStepCancelled")
|
|
357
|
+
params.put("data", gson.toJson(stepCancelledInfo))
|
|
358
|
+
|
|
359
|
+
val result = PluginResult(PluginResult.Status.OK, params)
|
|
360
|
+
result.keepCallback = true
|
|
361
|
+
|
|
362
|
+
journeyCallbackContext.sendPluginResult(result)
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
override fun onStepSkipped(stepSkippedInfo: StepSkippedInfo) {
|
|
366
|
+
Log.d("stepCallbacks", "onStepSkipped Step ${stepSkippedInfo.stepId} skipped!!")
|
|
367
|
+
val params = JSONObject()
|
|
368
|
+
params.put("event", "onStepSkipped")
|
|
369
|
+
params.put("data", gson.toJson(stepSkippedInfo))
|
|
370
|
+
|
|
371
|
+
val result = PluginResult(PluginResult.Status.OK, params)
|
|
372
|
+
result.keepCallback = true
|
|
373
|
+
|
|
374
|
+
journeyCallbackContext.sendPluginResult(result)
|
|
375
|
+
}
|
|
156
376
|
|
|
157
|
-
val result = PluginResult(PluginResult.Status.ERROR, params)
|
|
158
|
-
result.keepCallback = true
|
|
159
|
-
callbackContext.sendPluginResult(result)
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
)
|
|
163
377
|
}
|
|
378
|
+
|
|
379
|
+
fun convertImageToBase64String(bitmap: Bitmap?): String {
|
|
380
|
+
if (bitmap == null || bitmap.isRecycled) return ""
|
|
381
|
+
|
|
382
|
+
val baos = ByteArrayOutputStream()
|
|
383
|
+
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos)
|
|
384
|
+
val b = baos.toByteArray()
|
|
385
|
+
return Base64.encodeToString(b, Base64.DEFAULT)
|
|
386
|
+
}
|
|
387
|
+
|
|
164
388
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import IDWiseSDK
|
|
2
|
+
import Foundation
|
|
2
3
|
|
|
3
4
|
@objc(IDWiseCordovaSDK) class IDWiseCordovaSDK: CDVPlugin {
|
|
4
5
|
// Member variables go here.
|
|
@@ -17,25 +18,25 @@ import IDWiseSDK
|
|
|
17
18
|
} else if theme == "DARK" {
|
|
18
19
|
sdkTheme = .dark
|
|
19
20
|
}
|
|
21
|
+
|
|
20
22
|
IDWise.initialize(clientKey: clientKey, theme: sdkTheme) { err in
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
if let error = err {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
]
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
print(arguments)
|
|
31
|
-
|
|
32
|
-
var pluginResult = CDVPluginResult(
|
|
33
|
-
status: CDVCommandStatus_ERROR,
|
|
34
|
-
messageAs: arguments
|
|
35
|
-
)
|
|
36
|
-
pluginResult?.keepCallback = true
|
|
37
|
-
self.commandDelegate!.send(pluginResult, callbackId: command.callbackId)
|
|
25
|
+
do {
|
|
26
|
+
let jsonEncoder = JSONEncoder()
|
|
27
|
+
let jsonData = try jsonEncoder.encode(error)
|
|
28
|
+
let jsonResp = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
29
|
+
let arguments = ["event": "onError", "data": jsonResp] as [String: Any]
|
|
30
|
+
|
|
31
|
+
print(arguments)
|
|
38
32
|
|
|
33
|
+
var pluginResult = CDVPluginResult(
|
|
34
|
+
status: CDVCommandStatus_ERROR,
|
|
35
|
+
messageAs: arguments
|
|
36
|
+
)
|
|
37
|
+
pluginResult?.keepCallback = true
|
|
38
|
+
self.commandDelegate!.send(pluginResult, callbackId: command.callbackId)
|
|
39
|
+
} catch { print(error) }
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -45,79 +46,287 @@ import IDWiseSDK
|
|
|
45
46
|
let flowId = command.arguments[0] as? String ?? ""
|
|
46
47
|
let referenceNumber = command.arguments[1] as? String ?? ""
|
|
47
48
|
let locale = command.arguments[2] as? String ?? ""
|
|
49
|
+
let applicantDetails = command.arguments[3] as? String ?? ""
|
|
48
50
|
|
|
49
51
|
self.journeyCallbackId = command.callbackId
|
|
50
52
|
|
|
51
53
|
IDWise.startJourney(
|
|
52
|
-
|
|
54
|
+
flowId: flowId, referenceNumber: referenceNumber,
|
|
55
|
+
locale: locale, applicantDetails: nil, journeyDelegate: self)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@objc(startDynamicJourney:)
|
|
59
|
+
func startDynamicJourney(_ command: CDVInvokedUrlCommand) {
|
|
60
|
+
let flowId = command.arguments[0] as? String ?? ""
|
|
61
|
+
let referenceNumber = command.arguments[1] as? String ?? ""
|
|
62
|
+
let locale = command.arguments[2] as? String ?? ""
|
|
63
|
+
let applicantDetails = command.arguments[3] as? String ?? ""
|
|
64
|
+
|
|
65
|
+
self.journeyCallbackId = command.callbackId
|
|
66
|
+
|
|
67
|
+
IDWiseDynamic.startJourney(
|
|
68
|
+
flowId: flowId, referenceNumber: referenceNumber,
|
|
69
|
+
locale: locale, applicantDetails: nil, journeyDelegate: self, stepDelegate: self)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@objc(resumeJourney:)
|
|
73
|
+
func resumeJourney(_ command: CDVInvokedUrlCommand) {
|
|
74
|
+
let flowId = command.arguments[0] as? String ?? ""
|
|
75
|
+
let journeyId = command.arguments[1] as? String ?? ""
|
|
76
|
+
let locale = command.arguments[2] as? String ?? ""
|
|
77
|
+
|
|
78
|
+
self.journeyCallbackId = command.callbackId
|
|
79
|
+
|
|
80
|
+
IDWise.resumeJourney(
|
|
81
|
+
flowId: flowId, journeyId: journeyId,
|
|
53
82
|
locale: locale, journeyDelegate: self)
|
|
54
83
|
}
|
|
84
|
+
|
|
85
|
+
@objc(resumeDynamicJourney:)
|
|
86
|
+
func resumeDynamicJourney(_ command: CDVInvokedUrlCommand) {
|
|
87
|
+
let flowId = command.arguments[0] as? String ?? ""
|
|
88
|
+
let journeyId = command.arguments[1] as? String ?? ""
|
|
89
|
+
let locale = command.arguments[2] as? String ?? ""
|
|
90
|
+
|
|
91
|
+
self.journeyCallbackId = command.callbackId
|
|
92
|
+
|
|
93
|
+
IDWiseDynamic.resumeJourney(
|
|
94
|
+
flowId: flowId, journeyId: journeyId,
|
|
95
|
+
locale: locale, journeyDelegate: self, stepDelegate: self)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@objc(getJourneySummary:)
|
|
99
|
+
func getJourneySummary(_ command: CDVInvokedUrlCommand) {
|
|
100
|
+
print("swift getjourneysummary")
|
|
101
|
+
IDWiseDynamic.getJourneySummary(
|
|
102
|
+
callback: { journeySummary, error in
|
|
103
|
+
if let summary = journeySummary {
|
|
104
|
+
print("swift getjourneysummary success")
|
|
105
|
+
do {
|
|
106
|
+
let jsonEncoder = JSONEncoder()
|
|
107
|
+
let jsonData = try jsonEncoder.encode(summary)
|
|
108
|
+
let json = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
109
|
+
let arguments = ["journeySummary": json] as [String: Any]
|
|
110
|
+
var pluginResult = CDVPluginResult(
|
|
111
|
+
status: CDVCommandStatus_OK,
|
|
112
|
+
messageAs: arguments
|
|
113
|
+
)
|
|
114
|
+
pluginResult?.keepCallback = false
|
|
115
|
+
self.commandDelegate!.send(pluginResult, callbackId: command.callbackId)
|
|
116
|
+
} catch {
|
|
117
|
+
print(error)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
} else {
|
|
121
|
+
if let err = error {
|
|
122
|
+
do {
|
|
123
|
+
let jsonEncoder = JSONEncoder()
|
|
124
|
+
let jsonData = try jsonEncoder.encode(error)
|
|
125
|
+
let jsonResp = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
126
|
+
let arguments = ["error": jsonResp] as [String: Any]
|
|
127
|
+
var pluginResult = CDVPluginResult(
|
|
128
|
+
status: CDVCommandStatus_ERROR,
|
|
129
|
+
messageAs: arguments
|
|
130
|
+
)
|
|
131
|
+
pluginResult?.keepCallback = false
|
|
132
|
+
self.commandDelegate!.send(pluginResult, callbackId: command.callbackId)
|
|
133
|
+
} catch { print(error) }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@objc(startStep:)
|
|
141
|
+
func startStep(_ command: CDVInvokedUrlCommand) {
|
|
142
|
+
let stepId = command.arguments[0] as? String ?? ""
|
|
143
|
+
IDWiseDynamic.startStep(stepId: stepId)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@objc(skipStep:)
|
|
147
|
+
func skipStep(_ command: CDVInvokedUrlCommand) {
|
|
148
|
+
let stepId = command.arguments[0] as? String ?? ""
|
|
149
|
+
IDWiseDynamic.skipStep(stepId: stepId)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@objc(unloadSDK:)
|
|
153
|
+
func unloadSDK(_ command: CDVInvokedUrlCommand) {
|
|
154
|
+
IDWiseDynamic.unloadSDK()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@objc(finishJourney:)
|
|
158
|
+
func finishJourney(_ command: CDVInvokedUrlCommand) {
|
|
159
|
+
IDWiseDynamic.finishJourney()
|
|
160
|
+
}
|
|
55
161
|
}
|
|
56
162
|
|
|
57
163
|
extension IDWiseCordovaSDK: IDWiseSDKJourneyDelegate {
|
|
58
164
|
func onError(error: IDWiseSDKError) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
]
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
func
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
as [String: Any]
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
165
|
+
do {
|
|
166
|
+
let jsonEncoder = JSONEncoder()
|
|
167
|
+
let jsonData = try jsonEncoder.encode(error)
|
|
168
|
+
let jsonResp = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
169
|
+
let arguments = ["event": "onError", "data": jsonResp] as [String: Any]
|
|
170
|
+
var pluginResult = CDVPluginResult(
|
|
171
|
+
status: CDVCommandStatus_ERROR,
|
|
172
|
+
messageAs: arguments
|
|
173
|
+
)
|
|
174
|
+
pluginResult?.keepCallback = true
|
|
175
|
+
self.commandDelegate!.send(pluginResult, callbackId: self.journeyCallbackId)
|
|
176
|
+
} catch { print(error) }
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
func onJourneyCancelled(journeyCancelledInfo: JourneyCancelledInfo) {
|
|
180
|
+
|
|
181
|
+
let jsonEncoder = JSONEncoder()
|
|
182
|
+
do {
|
|
183
|
+
let jsonData = try jsonEncoder.encode(journeyCancelledInfo)
|
|
184
|
+
let json = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
185
|
+
let arguments = ["event": "onJourneyCancelled", "data": json] as [String: Any]
|
|
186
|
+
var pluginResult = CDVPluginResult(
|
|
187
|
+
status: CDVCommandStatus_OK,
|
|
188
|
+
messageAs: arguments
|
|
189
|
+
)
|
|
190
|
+
pluginResult?.keepCallback = true
|
|
191
|
+
self.commandDelegate!.send(pluginResult, callbackId: self.journeyCallbackId)
|
|
192
|
+
} catch {
|
|
193
|
+
print(error)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
func onJourneyStarted(journeyStartedInfo: JourneyStartedInfo) {
|
|
198
|
+
|
|
199
|
+
let jsonEncoder = JSONEncoder()
|
|
200
|
+
do {
|
|
201
|
+
let jsonData = try jsonEncoder.encode(journeyStartedInfo)
|
|
202
|
+
let json = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
203
|
+
let arguments = ["event": "onJourneyStarted", "data": json] as [String: Any]
|
|
204
|
+
var pluginResult = CDVPluginResult(
|
|
205
|
+
status: CDVCommandStatus_OK,
|
|
206
|
+
messageAs: arguments
|
|
207
|
+
)
|
|
208
|
+
pluginResult?.keepCallback = true
|
|
209
|
+
self.commandDelegate!.send(pluginResult, callbackId: self.journeyCallbackId)
|
|
210
|
+
} catch {
|
|
211
|
+
print(error)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
func onJourneyResumed(journeyResumedInfo: JourneyResumedInfo) {
|
|
216
|
+
|
|
217
|
+
let jsonEncoder = JSONEncoder()
|
|
218
|
+
do {
|
|
219
|
+
let jsonData = try jsonEncoder.encode(journeyResumedInfo)
|
|
220
|
+
let json = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
221
|
+
let arguments = ["event": "onJourneyResumed", "data": json] as [String: Any]
|
|
222
|
+
var pluginResult = CDVPluginResult(
|
|
223
|
+
status: CDVCommandStatus_OK,
|
|
224
|
+
messageAs: arguments
|
|
225
|
+
)
|
|
226
|
+
pluginResult?.keepCallback = true
|
|
227
|
+
self.commandDelegate!.send(pluginResult, callbackId: self.journeyCallbackId)
|
|
228
|
+
} catch {
|
|
229
|
+
print(error)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
func onJourneyCompleted(journeyCompletedInfo: JourneyCompletedInfo) {
|
|
235
|
+
|
|
236
|
+
let jsonEncoder = JSONEncoder()
|
|
237
|
+
do {
|
|
238
|
+
let jsonData = try jsonEncoder.encode(journeyCompletedInfo)
|
|
239
|
+
let json = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
240
|
+
let arguments = ["event": "onJourneyCompleted", "data": json] as [String: Any]
|
|
241
|
+
var pluginResult = CDVPluginResult(
|
|
242
|
+
status: CDVCommandStatus_OK,
|
|
243
|
+
messageAs: arguments
|
|
244
|
+
)
|
|
245
|
+
pluginResult?.keepCallback = true
|
|
246
|
+
self.commandDelegate!.send(pluginResult, callbackId: self.journeyCallbackId)
|
|
247
|
+
} catch {
|
|
248
|
+
print(error)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
extension IDWiseCordovaSDK: IDWiseSDKStepDelegate {
|
|
254
|
+
func onStepSkipped(stepSkippedInfo: StepSkippedInfo) {
|
|
255
|
+
|
|
256
|
+
let jsonEncoder = JSONEncoder()
|
|
257
|
+
do {
|
|
258
|
+
let jsonData = try jsonEncoder.encode(stepSkippedInfo)
|
|
259
|
+
let json = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
260
|
+
let arguments = ["event": "onStepSkipped", "data": json] as [String: Any]
|
|
261
|
+
var pluginResult = CDVPluginResult(
|
|
262
|
+
status: CDVCommandStatus_OK,
|
|
263
|
+
messageAs: arguments
|
|
264
|
+
)
|
|
265
|
+
pluginResult?.keepCallback = true
|
|
266
|
+
self.commandDelegate!.send(pluginResult, callbackId: self.journeyCallbackId)
|
|
267
|
+
} catch {
|
|
268
|
+
print(error)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
func onStepCancelled(stepCancelledInfo: StepCancelledInfo) {
|
|
273
|
+
|
|
274
|
+
let jsonEncoder = JSONEncoder()
|
|
275
|
+
do {
|
|
276
|
+
let jsonData = try jsonEncoder.encode(stepCancelledInfo)
|
|
277
|
+
let json = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
278
|
+
let arguments = ["event": "onStepCancelled", "data": json] as [String: Any]
|
|
279
|
+
var pluginResult = CDVPluginResult(
|
|
280
|
+
status: CDVCommandStatus_OK,
|
|
281
|
+
messageAs: arguments
|
|
282
|
+
)
|
|
283
|
+
pluginResult?.keepCallback = true
|
|
284
|
+
self.commandDelegate!.send(pluginResult, callbackId: self.journeyCallbackId)
|
|
285
|
+
} catch {
|
|
286
|
+
print(error)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Handling UI on each step capture and completion
|
|
291
|
+
func onStepResult(stepResultInfo: StepResultInfo) {
|
|
292
|
+
|
|
293
|
+
let jsonEncoder = JSONEncoder()
|
|
294
|
+
do {
|
|
295
|
+
let jsonData = try jsonEncoder.encode(stepResultInfo)
|
|
296
|
+
let json = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
297
|
+
let arguments = ["event": "onStepResult", "data": json] as [String: Any]
|
|
298
|
+
var pluginResult = CDVPluginResult(
|
|
299
|
+
status: CDVCommandStatus_OK,
|
|
300
|
+
messageAs: arguments
|
|
301
|
+
)
|
|
302
|
+
pluginResult?.keepCallback = true
|
|
303
|
+
self.commandDelegate!.send(pluginResult, callbackId: self.journeyCallbackId)
|
|
304
|
+
} catch {
|
|
305
|
+
print(error)
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
func onStepCaptured(stepCapturedInfo: StepCapturedInfo) {
|
|
310
|
+
|
|
311
|
+
do {
|
|
312
|
+
let originalImage = convertImageToBase64String(img: stepCapturedInfo.originalImage)
|
|
313
|
+
let croppedImage = convertImageToBase64String(img: stepCapturedInfo.croppedImage)
|
|
314
|
+
|
|
315
|
+
let arguments = ["event": "onStepCaptured", "data": "{\"stepId\":\"\(stepCapturedInfo.stepId)\", \"originalImage\":\"\(originalImage)\", \"croppedImage\":\"\(croppedImage)\"}"] as [String: Any]
|
|
316
|
+
|
|
317
|
+
var pluginResult = CDVPluginResult(
|
|
318
|
+
status: CDVCommandStatus_OK,
|
|
319
|
+
messageAs: arguments
|
|
320
|
+
)
|
|
321
|
+
pluginResult?.keepCallback = true
|
|
322
|
+
self.commandDelegate!.send(pluginResult, callbackId: self.journeyCallbackId)
|
|
323
|
+
} catch {
|
|
324
|
+
print(error)
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
func convertImageToBase64String(img: UIImage?) -> String {
|
|
330
|
+
return img?.jpegData(compressionQuality: 1)?.base64EncodedString() ?? ""
|
|
122
331
|
}
|
|
123
332
|
}
|
package/www/IDWiseCordovaSDK.js
CHANGED
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
var exec = require(
|
|
1
|
+
var exec = require("cordova/exec");
|
|
2
2
|
|
|
3
|
-
exports.initialize = function (clientKey,theme, error) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
exports.initialize = function (clientKey, theme, error) {
|
|
4
|
+
console.log("IDWISE.JS -> initialize");
|
|
5
|
+
function success(result) {
|
|
6
|
+
//dummy success required to pass to exec
|
|
7
|
+
}
|
|
8
|
+
function errorCb(ex) {
|
|
9
|
+
error(JSON.parse(ex.data));
|
|
10
|
+
}
|
|
11
|
+
exec(success, errorCb, "IDWiseCordovaSDK", "initialize", [clientKey, theme]);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
exports.startJourney = function (flowId, referenceNo, locale, applicantDetails, journeyCallback) {
|
|
15
|
+
console.log("applicant details");
|
|
16
|
+
console.log(applicantDetails);
|
|
17
|
+
function success(result) {
|
|
18
|
+
console.log(result);
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
case "onJourneyCancelled":
|
|
29
|
-
journeyCallback.onJourneyCancelled(result.data);
|
|
30
|
-
break;
|
|
20
|
+
switch (result.event) {
|
|
21
|
+
case "onJourneyStarted":
|
|
22
|
+
journeyCallback.onJourneyStarted(JSON.parse(result.data));
|
|
23
|
+
break;
|
|
24
|
+
case "onJourneyResumed":
|
|
25
|
+
journeyCallback.onJourneyResumed(JSON.parse(result.data));
|
|
26
|
+
break;
|
|
27
|
+
case "onJourneyCompleted":
|
|
28
|
+
journeyCallback.onJourneyCompleted(JSON.parse(result.data));
|
|
29
|
+
break;
|
|
30
|
+
case "onJourneyCancelled":
|
|
31
|
+
journeyCallback.onJourneyCancelled(JSON.parse(result.data));
|
|
32
|
+
break;
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
34
|
+
default:
|
|
35
|
+
console.log("unknown event call", result.event);
|
|
35
36
|
}
|
|
37
|
+
}
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
39
|
+
function error(error) {
|
|
40
|
+
journeyCallback.onError(JSON.parse(error.data));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exec(success, error, "IDWiseCordovaSDK", "startJourney", [flowId, referenceNo, locale, applicantDetails]);
|
|
44
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
var exec = require("cordova/exec");
|
|
2
|
+
|
|
3
|
+
exports.initialize = function (clientKey, theme, initializeError) {
|
|
4
|
+
console.log("IDWISE-Dynamic.JS -> initialize");
|
|
5
|
+
function success(result) {
|
|
6
|
+
//dummy success required to pass to exec
|
|
7
|
+
}
|
|
8
|
+
function errorCb(ex) {
|
|
9
|
+
console.log("IDWISE-Dynamic.JS -> errorCb");
|
|
10
|
+
console.log(ex);
|
|
11
|
+
initializeError(JSON.parse(ex.data));
|
|
12
|
+
}
|
|
13
|
+
exec(success, errorCb, "IDWiseCordovaSDK", "initialize", [clientKey, theme]);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.startJourney = function (flowId, referenceNo, locale, applicantDetails, journeyCallback, stepCallback) {
|
|
17
|
+
console.log("IDWISE-Dynamic.JS -> startJourney");
|
|
18
|
+
function success(result) {
|
|
19
|
+
triggerCallbacks(result, journeyCallback, stepCallback);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function error(error) {
|
|
23
|
+
console.log("onError ", error.data);
|
|
24
|
+
journeyCallback.onError(error.data);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exec(success, error, "IDWiseCordovaSDK", "startDynamicJourney", [flowId, referenceNo, locale, applicantDetails]);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.resumeJourney = function (flowId, journeyId, locale, journeyCallback, stepCallback) {
|
|
31
|
+
console.log("IDWISE-Dynamic.JS -> resumeJourney");
|
|
32
|
+
function success(result) {
|
|
33
|
+
triggerCallbacks(result, journeyCallback, stepCallback);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function error(error) {
|
|
37
|
+
console.log("onError ", error.data);
|
|
38
|
+
journeyCallback.onError(error.data);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exec(success, error, "IDWiseCordovaSDK", "resumeDynamicJourney", [flowId, journeyId, locale]);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.startStep = function (stepId) {
|
|
45
|
+
console.log("IDWISE-Dynamic.JS -> startStep", stepId);
|
|
46
|
+
function success(result) {}
|
|
47
|
+
function error(ex) {
|
|
48
|
+
console.log("IDWISE-Dynamic.JS -> errorCb", ex);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
exec(success, error, "IDWiseCordovaSDK", "startStep", [stepId]);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
exports.skipStep = function (stepId) {
|
|
55
|
+
console.log("IDWISE-Dynamic.JS -> skipStep", stepId);
|
|
56
|
+
function success(result) {}
|
|
57
|
+
function error(ex) {
|
|
58
|
+
console.log("IDWISE-Dynamic.JS -> errorCb", ex);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exec(success, error, "IDWiseCordovaSDK", "skipStep", [stepId]);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.unloadSKD = function () {
|
|
65
|
+
console.log("IDWISE-Dynamic.JS -> unloadSKD");
|
|
66
|
+
function success(result) {}
|
|
67
|
+
function error(ex) {
|
|
68
|
+
console.log("IDWISE-Dynamic.JS -> errorCb", ex);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
exec(success, error, "IDWiseCordovaSDK", "unloadSKD", []);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
exports.finishJourney = function () {
|
|
75
|
+
console.log("IDWISE-Dynamic.JS -> finishJourney");
|
|
76
|
+
function success(result) {}
|
|
77
|
+
function error(ex) {
|
|
78
|
+
console.log("IDWISE-Dynamic.JS -> errorCb", ex);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exec(success, error, "IDWiseCordovaSDK", "finishJourney", []);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
exports.getJourneySummary = function (success, error) {
|
|
85
|
+
console.log("IDWISE-Dynamic.JS -> getJourneySummary");
|
|
86
|
+
|
|
87
|
+
function onSuccess(response) {
|
|
88
|
+
success(JSON.parse(response.journeySummary));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function onError(errorResponse) {
|
|
92
|
+
console.log(`getjourneysummary error ${JSON.stringify(errorResponse)}`);
|
|
93
|
+
error(JSON.parse(errorResponse.error));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
exec(onSuccess, onError, "IDWiseCordovaSDK", "getJourneySummary", []);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
function triggerCallbacks(result, journeyCallback, stepCallback) {
|
|
100
|
+
switch (result.event) {
|
|
101
|
+
case "onJourneyStarted":
|
|
102
|
+
journeyCallback.onJourneyStarted(JSON.parse(result.data));
|
|
103
|
+
break;
|
|
104
|
+
case "onJourneyResumed":
|
|
105
|
+
journeyCallback.onJourneyResumed(JSON.parse(result.data));
|
|
106
|
+
break;
|
|
107
|
+
case "onJourneyCompleted":
|
|
108
|
+
journeyCallback.onJourneyCompleted(JSON.parse(result.data));
|
|
109
|
+
break;
|
|
110
|
+
case "onJourneyCancelled":
|
|
111
|
+
journeyCallback.onJourneyCancelled(JSON.parse(result.data));
|
|
112
|
+
break;
|
|
113
|
+
|
|
114
|
+
case "onStepCaptured":
|
|
115
|
+
stepCallback.onStepCaptured(JSON.parse(result.data));
|
|
116
|
+
break;
|
|
117
|
+
case "onStepResult":
|
|
118
|
+
stepCallback.onStepResult(JSON.parse(result.data));
|
|
119
|
+
break;
|
|
120
|
+
case "onStepCancelled":
|
|
121
|
+
stepCallback.onStepCancelled(JSON.parse(result.data));
|
|
122
|
+
break;
|
|
123
|
+
case "onStepSkipped":
|
|
124
|
+
stepCallback.onStepSkipped(JSON.parse(result.data));
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
default:
|
|
128
|
+
console.log("unknown event call", result.event);
|
|
129
|
+
}
|
|
130
|
+
}
|