idwise-cordova-sdk 0.1.0 → 4.6.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
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="idwise-cordova-sdk" version="
|
|
2
|
+
<plugin id="idwise-cordova-sdk" version="4.6.0" 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
|
-
<!-- <clobbers target="IDWise" />-->
|
|
8
7
|
</js-module>
|
|
9
8
|
<platform name="ios">
|
|
10
9
|
<config-file parent="/*" target="config.xml">
|
|
@@ -22,7 +21,7 @@
|
|
|
22
21
|
<source url="https://github.com/idwise/ios-sdk.git" />
|
|
23
22
|
</config>
|
|
24
23
|
<pods use-frameworks="true">
|
|
25
|
-
<pod name="IDWise" />
|
|
24
|
+
<pod name="IDWise" spec="4.6.9" />
|
|
26
25
|
</pods>
|
|
27
26
|
</podspec>
|
|
28
27
|
</platform>
|
|
@@ -59,8 +59,17 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
59
59
|
) {
|
|
60
60
|
|
|
61
61
|
IDWise.initialize(clientKey, theme) { error: IDWiseSDKError? ->
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
val params = JSONObject()
|
|
63
|
+
params.put("event", "onError")
|
|
64
|
+
|
|
65
|
+
val data = JSONObject()
|
|
66
|
+
data.put("errorCode", error!!.errorCode)
|
|
67
|
+
data.put("message", error!!.message)
|
|
68
|
+
params.put("data", data)
|
|
69
|
+
|
|
70
|
+
val result = PluginResult(PluginResult.Status.ERROR, params)
|
|
71
|
+
result.keepCallback = true
|
|
72
|
+
callbackContext.sendPluginResult(result)
|
|
64
73
|
}
|
|
65
74
|
}
|
|
66
75
|
|
|
@@ -9,14 +9,31 @@ import IDWiseSDK
|
|
|
9
9
|
@objc(initialize:)
|
|
10
10
|
func initialize(_ command: CDVInvokedUrlCommand) {
|
|
11
11
|
let clientKey = command.arguments[0] as? String ?? ""
|
|
12
|
-
|
|
12
|
+
let theme = command.arguments[1] as? String ?? ""
|
|
13
|
+
|
|
14
|
+
var sdkTheme: IDWiseSDKTheme = .systemDefault
|
|
15
|
+
if theme == "LIGHT" {
|
|
16
|
+
sdkTheme = .light
|
|
17
|
+
} else if theme == "DARK" {
|
|
18
|
+
sdkTheme = .dark
|
|
19
|
+
}
|
|
20
|
+
IDWise.initialize(clientKey: clientKey, theme: sdkTheme) { err in
|
|
13
21
|
// Deal with error here
|
|
14
22
|
if let error = err {
|
|
15
|
-
|
|
23
|
+
let arguments =
|
|
24
|
+
[
|
|
25
|
+
"event": "onError",
|
|
26
|
+
"data": ["errorCode": error.code, "message": error.message] as [String: Any],
|
|
27
|
+
]
|
|
28
|
+
as [String: Any]
|
|
29
|
+
|
|
30
|
+
print(arguments)
|
|
31
|
+
|
|
16
32
|
var pluginResult = CDVPluginResult(
|
|
17
33
|
status: CDVCommandStatus_ERROR,
|
|
18
|
-
messageAs:
|
|
34
|
+
messageAs: arguments
|
|
19
35
|
)
|
|
36
|
+
pluginResult?.keepCallback = true
|
|
20
37
|
self.commandDelegate!.send(pluginResult, callbackId: command.callbackId)
|
|
21
38
|
|
|
22
39
|
}
|
|
@@ -26,19 +43,28 @@ import IDWiseSDK
|
|
|
26
43
|
@objc(startJourney:)
|
|
27
44
|
func startJourney(_ command: CDVInvokedUrlCommand) {
|
|
28
45
|
let flowId = command.arguments[0] as? String ?? ""
|
|
46
|
+
let referenceNumber = command.arguments[1] as? String ?? ""
|
|
47
|
+
let locale = command.arguments[2] as? String ?? ""
|
|
48
|
+
|
|
29
49
|
self.journeyCallbackId = command.callbackId
|
|
30
50
|
|
|
31
51
|
IDWise.startJourney(
|
|
32
|
-
journeyDefinitionId: flowId, referenceNumber:
|
|
33
|
-
locale:
|
|
52
|
+
journeyDefinitionId: flowId, referenceNumber: referenceNumber,
|
|
53
|
+
locale: locale, journeyDelegate: self)
|
|
34
54
|
}
|
|
35
55
|
}
|
|
36
56
|
|
|
37
57
|
extension IDWiseCordovaSDK: IDWiseSDKJourneyDelegate {
|
|
38
58
|
func onError(error: IDWiseSDKError) {
|
|
59
|
+
let arguments =
|
|
60
|
+
[
|
|
61
|
+
"event": "onError",
|
|
62
|
+
"data": ["errorCode": error.code, "message": error.message] as [String: Any],
|
|
63
|
+
]
|
|
64
|
+
as [String: Any]
|
|
39
65
|
var pluginResult = CDVPluginResult(
|
|
40
66
|
status: CDVCommandStatus_ERROR,
|
|
41
|
-
messageAs:
|
|
67
|
+
messageAs: arguments
|
|
42
68
|
)
|
|
43
69
|
pluginResult?.keepCallback = true
|
|
44
70
|
self.commandDelegate!.send(pluginResult, callbackId: self.journeyCallbackId)
|
package/www/IDWiseCordovaSDK.js
CHANGED
|
@@ -5,7 +5,10 @@ exports.initialize = function (clientKey,theme, error) {
|
|
|
5
5
|
function success(result){
|
|
6
6
|
//dummy success required to pass to exec
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
function errorCb(ex){
|
|
9
|
+
error(ex.data);
|
|
10
|
+
}
|
|
11
|
+
exec(success, errorCb, 'IDWiseCordovaSDK', 'initialize', [clientKey, theme]);
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
|