@qore-id/react-native-qoreid-sdk 1.1.2 → 1.1.4
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/android/build.gradle
CHANGED
|
@@ -6,7 +6,6 @@ buildscript {
|
|
|
6
6
|
mavenCentral()
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
dependencies {
|
|
11
10
|
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
11
|
// noinspection DifferentKotlinGradleVersion
|
|
@@ -65,16 +64,6 @@ android {
|
|
|
65
64
|
disable "GradleCompatible"
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
compileOptions {
|
|
69
|
-
sourceCompatibility JavaVersion.VERSION_1_8
|
|
70
|
-
targetCompatibility JavaVersion.VERSION_1_8
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
kotlinOptions {
|
|
74
|
-
jvmTarget = "1.8"
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
67
|
}
|
|
79
68
|
|
|
80
69
|
repositories {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package com.qoreidsdk
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import android.app.Activity
|
|
5
4
|
import android.content.Intent
|
|
6
5
|
import android.os.Build
|
|
@@ -18,46 +17,46 @@ import com.qoreid.sdk.core.models.QoreIDResult
|
|
|
18
17
|
import com.qoreid.sdk.core.models.SuccessResult
|
|
19
18
|
import java.util.HashMap
|
|
20
19
|
|
|
21
|
-
|
|
22
20
|
class QoreidSdkModule(val reactContext: ReactApplicationContext) :
|
|
23
|
-
|
|
21
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
24
22
|
private var qoreIdResult: QoreIDResult? = null
|
|
25
23
|
|
|
26
24
|
private val activityEventListener =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
object : BaseActivityEventListener() {
|
|
26
|
+
override fun onActivityResult(
|
|
27
|
+
activity: Activity?,
|
|
28
|
+
requestCode: Int,
|
|
29
|
+
resultCode: Int,
|
|
30
|
+
intent: Intent?
|
|
31
|
+
) {
|
|
32
|
+
|
|
33
|
+
if (resultCode == QORE_ID_RESULT_CODE && intent != null) {
|
|
34
|
+
qoreIdResult =
|
|
35
|
+
if (Build.VERSION.SDK_INT < 33) {
|
|
36
|
+
intent.extras?.getSerializable(QORE_ID_RESULT_EXTRA_KEY) as
|
|
37
|
+
QoreIDResult
|
|
38
|
+
} else {
|
|
39
|
+
intent.extras?.getSerializable(
|
|
40
|
+
QORE_ID_RESULT_EXTRA_KEY,
|
|
41
|
+
QoreIDResult::class.java
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
processQoreIDResult(reactContext, qoreIdResult!!)
|
|
43
45
|
}
|
|
44
|
-
processQoreIDResult(reactContext, qoreIdResult!!)
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
49
|
init {
|
|
52
50
|
reactContext.addActivityEventListener(activityEventListener)
|
|
53
51
|
QoreIDSdk.Callbacks.onFlowRequestId {
|
|
54
52
|
Log.i("QORE_ID", it.toString())
|
|
55
53
|
|
|
56
|
-
val event =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
val event =
|
|
55
|
+
Arguments.createMap().apply {
|
|
56
|
+
putString("data", it.toString())
|
|
57
|
+
putString("message", "QOREID SDK INITIALIZED")
|
|
58
|
+
putString("event", "SESSION_RESULT")
|
|
59
|
+
}
|
|
61
60
|
|
|
62
61
|
sendEvent(reactContext, "onResult", event)
|
|
63
62
|
}
|
|
@@ -72,89 +71,89 @@ class QoreidSdkModule(val reactContext: ReactApplicationContext) :
|
|
|
72
71
|
val data = readableData.toHashMap()
|
|
73
72
|
|
|
74
73
|
if (currentActivity == null) {
|
|
75
|
-
Log.e("Error", "No current activity")
|
|
74
|
+
Log.e("Error", "No current activity")
|
|
76
75
|
return
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
val config = data?.get("config") as? HashMap<*, *>
|
|
80
79
|
val apD = data?.get("applicantData") as? HashMap<*, *>
|
|
81
|
-
val applicantData =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
val applicantData =
|
|
81
|
+
ApplicantData(
|
|
82
|
+
apD?.get("firstName") as String,
|
|
83
|
+
apD?.get("lastName") as String,
|
|
84
|
+
apD?.get("phoneNumber") as String?,
|
|
85
|
+
apD?.get("middleName") as String?,
|
|
86
|
+
apD?.get("dob") as String?,
|
|
87
|
+
apD?.get("email") as String?,
|
|
88
|
+
apD?.get("gender") as String?
|
|
89
|
+
)
|
|
92
90
|
|
|
93
91
|
val adD = data?.get("addressData") as? HashMap<*, *>
|
|
94
|
-
val addressData =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
val addressData =
|
|
93
|
+
AddressData(
|
|
94
|
+
adD?.get("address") as String?,
|
|
95
|
+
adD?.get("city") as String?,
|
|
96
|
+
adD?.get("lga") as String?,
|
|
97
|
+
adD?.get("state") as String?,
|
|
98
|
+
)
|
|
100
99
|
val flowId = config?.get("flowId") as? Double
|
|
101
100
|
|
|
102
|
-
val qoreIDParams =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
101
|
+
val qoreIDParams =
|
|
102
|
+
if (flowId?.toLong() != 0L) {
|
|
103
|
+
QoreIDParams()
|
|
104
|
+
.clientId(config?.get("clientId") as String)
|
|
105
|
+
.customerReference(config?.get("customerReference") as String)
|
|
106
|
+
.inputData(applicantData, addressData)
|
|
107
|
+
.ocrAcceptedDocuments(data?.get("acceptedDocuments") as List<String>)
|
|
108
|
+
.workflow(flowId!!.toLong())
|
|
109
|
+
// .workflowDefaultIdentity(config?.get("defaultIdType") as
|
|
110
|
+
// String)
|
|
111
|
+
} else {
|
|
112
|
+
QoreIDParams()
|
|
113
|
+
.clientId(config?.get("clientId") as String)
|
|
114
|
+
.customerReference(config?.get("customerReference") as String)
|
|
115
|
+
.inputData(applicantData, addressData)
|
|
116
|
+
.ocrAcceptedDocuments(data?.get("acceptedDocuments") as List<String>)
|
|
117
|
+
.collection(config?.get("productCode") as String)
|
|
118
|
+
}
|
|
118
119
|
|
|
119
|
-
QoreIDSdk.s(BuildConfig.s)
|
|
120
|
+
QoreIDSdk.s(BuildConfig.s)
|
|
120
121
|
QoreIDSdk.params(qoreIDParams)
|
|
121
122
|
QoreIDSdk.launch(requireNotNull(currentActivity))
|
|
122
|
-
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
fun processQoreIDResult(context: ReactContext, qoreIdResult: QoreIDResult) {
|
|
126
126
|
when (qoreIdResult) {
|
|
127
127
|
is ErrorResult -> {
|
|
128
128
|
// Handle error.
|
|
129
|
-
val event =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
val event =
|
|
130
|
+
Arguments.createMap().apply {
|
|
131
|
+
putString("code", qoreIdResult.code.toString())
|
|
132
|
+
putString("data", qoreIdResult.data.toString())
|
|
133
|
+
putString("message", qoreIdResult.message)
|
|
134
|
+
putString("event", "ERROR_RESULT")
|
|
135
|
+
}
|
|
135
136
|
|
|
136
137
|
sendEvent(context, "onResult", event)
|
|
137
|
-
|
|
138
138
|
}
|
|
139
|
-
|
|
140
139
|
is SuccessResult -> {
|
|
141
140
|
// Handle success.
|
|
142
|
-
val event =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
val event =
|
|
142
|
+
Arguments.createMap().apply {
|
|
143
|
+
putString("data", qoreIdResult.data.toString())
|
|
144
|
+
putString("message", qoreIdResult.message)
|
|
145
|
+
putString("event", "SUCCESS_RESULT")
|
|
146
|
+
}
|
|
147
147
|
|
|
148
148
|
sendEvent(context, "onResult", event)
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
154
153
|
private fun sendEvent(reactContext: ReactContext, eventName: String, params: WritableMap?) {
|
|
155
154
|
reactContext
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
156
|
+
.emit(eventName, params)
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
companion object {
|
|
@@ -162,7 +161,7 @@ class QoreidSdkModule(val reactContext: ReactApplicationContext) :
|
|
|
162
161
|
|
|
163
162
|
@JvmStatic
|
|
164
163
|
fun initialize(activity: Activity) {
|
|
165
|
-
QoreIDSdk.initialize(activity)
|
|
164
|
+
QoreIDSdk.initialize(activity)
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
167
|
}
|