@qore-id/react-native-qoreid-sdk 1.0.9 → 1.1.1
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/README.md +1 -211
- package/android/build.gradle +2 -2
- package/android/src/main/AndroidManifest.xml +0 -1
- package/android/src/main/java/com/qoreidsdk/QoreidSdkModule.kt +45 -34
- package/ios/QoreidSdk-Bridging-Header.h +7 -0
- package/ios/QoreidSdk.m +21 -0
- package/ios/QoreidSdk.swift +137 -0
- package/ios/QoreidSdk.xcodeproj/project.pbxproj +22 -4
- package/ios/QoreidSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/QoreidSdk.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +5 -0
- package/ios/QoreidSdk.xcodeproj/project.xcworkspace/xcuserdata/e.ugwuoke.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/QoreidSdk.xcodeproj/project.xcworkspace/xcuserdata/e.ugwuoke.xcuserdatad/WorkspaceSettings.xcsettings +14 -0
- package/ios/QoreidSdk.xcodeproj/xcuserdata/e.ugwuoke.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/ViewController.swift +22 -0
- package/lib/commonjs/index.js +10 -42
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/qoreIdSdk.js +48 -0
- package/lib/commonjs/qoreIdSdk.js.map +1 -0
- package/lib/commonjs/types.d.js +0 -4
- package/lib/commonjs/utils.js +1 -2
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/index.js +1 -35
- package/lib/module/index.js.map +1 -1
- package/lib/module/qoreIdSdk.js +42 -0
- package/lib/module/qoreIdSdk.js.map +1 -0
- package/lib/module/types.d.js +1 -1
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/qoreIdSdk.d.ts +15 -0
- package/lib/typescript/qoreIdSdk.d.ts.map +1 -0
- package/package.json +3 -7
- package/qore-id-react-native-qoreid-sdk.podspec +4 -4
- package/src/index.tsx +1 -48
- package/src/qoreIdSdk.tsx +47 -0
- package/src/types.d.ts +13 -57
- package/android/Untitled +0 -0
- package/ios/QoreidSdk.h +0 -12
- package/ios/QoreidSdk.mm +0 -27
- package/lib/commonjs/qoreIdButton.android.js +0 -105
- package/lib/commonjs/qoreIdButton.android.js.map +0 -1
- package/lib/commonjs/qoreIdButton.ios.js +0 -129
- package/lib/commonjs/qoreIdButton.ios.js.map +0 -1
- package/lib/module/qoreIdButton.android.js +0 -95
- package/lib/module/qoreIdButton.android.js.map +0 -1
- package/lib/module/qoreIdButton.ios.js +0 -121
- package/lib/module/qoreIdButton.ios.js.map +0 -1
- package/lib/typescript/qoreIdButton.android.d.ts +0 -18
- package/lib/typescript/qoreIdButton.android.d.ts.map +0 -1
- package/lib/typescript/qoreIdButton.ios.d.ts +0 -4
- package/lib/typescript/qoreIdButton.ios.d.ts.map +0 -1
- package/src/qoreIdButton.android.tsx +0 -139
package/README.md
CHANGED
|
@@ -10,214 +10,4 @@ npm install --save @qore-id/react-native-qoreid-sdk
|
|
|
10
10
|
|
|
11
11
|
```c yarn
|
|
12
12
|
yarn add @qore-id/react-native-qoreid-sdk
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### Android
|
|
16
|
-
|
|
17
|
-
Add the following to your `app/build.gradle`
|
|
18
|
-
|
|
19
|
-
```groovy
|
|
20
|
-
repositories {
|
|
21
|
-
mavenCentral()
|
|
22
|
-
google()
|
|
23
|
-
maven {
|
|
24
|
-
url "https://repo.qoreid.com/repository/maven-releases/"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Add this snippet of code to your `~/java/com.<app name>/MainActivity`
|
|
30
|
-
|
|
31
|
-
```java
|
|
32
|
-
@Override
|
|
33
|
-
protected void onCreate(Bundle savedInstanceState) {
|
|
34
|
-
super.onCreate(savedInstanceState);
|
|
35
|
-
QoreidSdkModule.initialize(this);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Add this import statement above the class
|
|
41
|
-
|
|
42
|
-
```java
|
|
43
|
-
import com.qoreidsdk.QoreidSdkModule;
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
<!-- ### iOS
|
|
48
|
-
|
|
49
|
-
From your root directory
|
|
50
|
-
|
|
51
|
-
```sh
|
|
52
|
-
npm i react-native-webview
|
|
53
|
-
``` -->
|
|
54
|
-
|
|
55
|
-
## Permissions
|
|
56
|
-
|
|
57
|
-
Certain services on QoreID require device permissions to work properly. Follow the instructions [here](https://docs.qoreid.com/docs/permissions) to add the required permissions to your `~/android/app/src/main/AndroidManifest.xml` file.
|
|
58
|
-
|
|
59
|
-
Verifind required permissions
|
|
60
|
-
|
|
61
|
-
```xml
|
|
62
|
-
...
|
|
63
|
-
<!-- Required for Verifind -->
|
|
64
|
-
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
|
|
65
|
-
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
66
|
-
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
67
|
-
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
|
68
|
-
...
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Usage
|
|
72
|
-
|
|
73
|
-
```tsx
|
|
74
|
-
//verify.tsx
|
|
75
|
-
import React from 'react';
|
|
76
|
-
import { Button, View } from 'react-native';
|
|
77
|
-
import { QoreIdSdk } from '@qore-id/react-native-qoreid-sdk';
|
|
78
|
-
|
|
79
|
-
function App() {
|
|
80
|
-
|
|
81
|
-
const onError = (data) => {
|
|
82
|
-
console.error(data);
|
|
83
|
-
Alert.alert('Error', data);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const onSuccess = (data) => {
|
|
87
|
-
console.debug(data);
|
|
88
|
-
Alert.alert('Sumitted', data);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
QoreIdSdk.events(onSuccess, onError);
|
|
92
|
-
|
|
93
|
-
function onSubmit() {
|
|
94
|
-
const formData = {
|
|
95
|
-
flowId: parseInt(flowId),
|
|
96
|
-
clientId: clientId,
|
|
97
|
-
productCode: selectedProductId,
|
|
98
|
-
customerReference: customerRef,
|
|
99
|
-
applicantData: {
|
|
100
|
-
firstName: firstName,
|
|
101
|
-
middleName: middleName,
|
|
102
|
-
lastName: lastName,
|
|
103
|
-
gender: gender,
|
|
104
|
-
phoneNumber: phoneNumber,
|
|
105
|
-
email: email,
|
|
106
|
-
},
|
|
107
|
-
identityData: {
|
|
108
|
-
idType: idCardType,
|
|
109
|
-
idNumber: idNumber,
|
|
110
|
-
},
|
|
111
|
-
addressData: {
|
|
112
|
-
address: phyAddress,
|
|
113
|
-
city: city,
|
|
114
|
-
lga: lga,
|
|
115
|
-
},
|
|
116
|
-
ocrAcceptedDocuments:
|
|
117
|
-
'DRIVERS_LICENSE_NGA,VOTERS_CARD_NGA,NIN_SLIP_NGA,PASSPORT_NGA',
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
QoreIdSdk.launchQoreId(formData);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<View>
|
|
125
|
-
<Button title="Launch QoreIdSdk" onPress={onSubmit} />
|
|
126
|
-
</View>
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
You can also use the QoreIdButton component to trigger verifications (which will be deprecated in the next major release):
|
|
132
|
-
|
|
133
|
-
```tsx
|
|
134
|
-
//verify.tsx
|
|
135
|
-
import React from 'react'
|
|
136
|
-
import { QoreIdButton } from '@qore-id/react-native-qoreid-sdk';
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
function App() {
|
|
140
|
-
|
|
141
|
-
const customButton = ({ onPress }) => <Button onPress={onPress} title="QoreId Button" />
|
|
142
|
-
|
|
143
|
-
const onError = (data) => {
|
|
144
|
-
console.error(data);
|
|
145
|
-
Alert.alert('Error', data);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const onSumitted = (data) => {
|
|
149
|
-
console.debug(data);
|
|
150
|
-
Alert.alert('Sumitted', data);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const onClosed = (data) => {
|
|
154
|
-
console.debug(data);
|
|
155
|
-
Alert.alert('Closed', data);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
return (
|
|
159
|
-
<View>
|
|
160
|
-
{/* Other components */}
|
|
161
|
-
<QoreIdButton
|
|
162
|
-
title="Verify"
|
|
163
|
-
flowId=""
|
|
164
|
-
clientId="" {/* Required */}
|
|
165
|
-
productCode="" {/* Required */}
|
|
166
|
-
customerReference="" {/* Required */}
|
|
167
|
-
applicantData={{
|
|
168
|
-
firstName:"",
|
|
169
|
-
middleName:"",
|
|
170
|
-
lastName:"",
|
|
171
|
-
gender:"",
|
|
172
|
-
phoneNumber:"",
|
|
173
|
-
email:"",
|
|
174
|
-
}}
|
|
175
|
-
identityData={{ idType: "", idNumber:"" }}
|
|
176
|
-
addressData={{
|
|
177
|
-
address: "",
|
|
178
|
-
city:"",
|
|
179
|
-
lga:"",
|
|
180
|
-
}}
|
|
181
|
-
ocrAcceptedDocuments="DRIVERS_LICENSE_NGA,VOTERS_CARD_NGA,NIN_SLIP_NGA,PASSPORT_NGA"
|
|
182
|
-
onQoreIDSdkSubmitted={onSumitted}
|
|
183
|
-
onQoreIDSdkError={onError}
|
|
184
|
-
onQoreIDSdkClosed={onClosed}
|
|
185
|
-
render={customButton}
|
|
186
|
-
/>
|
|
187
|
-
</View>
|
|
188
|
-
)
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Utilities
|
|
194
|
-
|
|
195
|
-
QoreId SDK exposes utilities that you can easily use
|
|
196
|
-
|
|
197
|
-
```coffeescript
|
|
198
|
-
|
|
199
|
-
import React, {useRef} from 'react'
|
|
200
|
-
import { QoreIdButton, utils } from '@qore-id/react-native-qoreid-sdk';
|
|
201
|
-
|
|
202
|
-
function App() {
|
|
203
|
-
|
|
204
|
-
// Array of string
|
|
205
|
-
//For more information check -> https://docs.qoreid.com/docs/product-codes
|
|
206
|
-
const productIds = utils.productCodes;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
//An array of accepted documents in a specific country
|
|
210
|
-
//For more information check -> https://docs.qoreid.com/docs/ocr-accepted-documents#accepted-documents-for-ocr-verifications
|
|
211
|
-
const ocrLists = utils.acceptedDocuments["Nigeria"]
|
|
212
|
-
...
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
## CHANGE LOGS
|
|
218
|
-
|
|
219
|
-
#### 1.0.9
|
|
220
|
-
|
|
221
|
-
- Added qoreid initialization function. You can now launche the sdk in your code implementation - offering you more control.
|
|
222
|
-
- Addition of event listener `QoreIdSdk.events` to listen to events from the sdk.
|
|
223
|
-
- QoreIdButton component will be deprecated in the next major release. Use `QoreIdSdk.launchQoreId` instead.
|
|
13
|
+
```
|
package/android/build.gradle
CHANGED
|
@@ -92,8 +92,8 @@ dependencies {
|
|
|
92
92
|
// For < 0.71, this will be from the local maven repo
|
|
93
93
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
94
94
|
//noinspection GradleDynamicVersion
|
|
95
|
-
implementation 'com.qoreid:qoreid-sdk:1.1.
|
|
96
|
-
implementation
|
|
95
|
+
implementation 'com.qoreid:qoreid-sdk:1.1.40'
|
|
96
|
+
// implementation 'com.qoreid:qoreid-sdk-dev-min:1.1.43'
|
|
97
97
|
implementation "com.facebook.react:react-native:+"
|
|
98
98
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
99
99
|
|
|
@@ -7,7 +7,6 @@ import android.os.Build
|
|
|
7
7
|
import android.util.Log
|
|
8
8
|
import com.facebook.react.bridge.*
|
|
9
9
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
10
|
-
import com.google.gson.Gson
|
|
11
10
|
import com.qoreid.sdk.core.QoreIDParams
|
|
12
11
|
import com.qoreid.sdk.core.QoreIDSdk
|
|
13
12
|
import com.qoreid.sdk.core.QoreIDSdk.QORE_ID_RESULT_CODE
|
|
@@ -17,14 +16,12 @@ import com.qoreid.sdk.core.models.ApplicantData
|
|
|
17
16
|
import com.qoreid.sdk.core.models.ErrorResult
|
|
18
17
|
import com.qoreid.sdk.core.models.QoreIDResult
|
|
19
18
|
import com.qoreid.sdk.core.models.SuccessResult
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
import java.util.HashMap
|
|
22
20
|
|
|
23
21
|
|
|
24
22
|
class QoreidSdkModule(val reactContext: ReactApplicationContext) :
|
|
25
|
-
ReactContextBaseJavaModule(reactContext){
|
|
26
|
-
private var qoreIdResult: QoreIDResult? = null
|
|
27
|
-
|
|
23
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
24
|
+
private var qoreIdResult: QoreIDResult? = null
|
|
28
25
|
|
|
29
26
|
private val activityEventListener =
|
|
30
27
|
object : BaseActivityEventListener() {
|
|
@@ -53,6 +50,17 @@ class QoreidSdkModule(val reactContext: ReactApplicationContext) :
|
|
|
53
50
|
|
|
54
51
|
init {
|
|
55
52
|
reactContext.addActivityEventListener(activityEventListener)
|
|
53
|
+
// QoreIDSdk.Callbacks.onFlowRequestId {
|
|
54
|
+
// Log.i("QORE_ID", it.toString())
|
|
55
|
+
//
|
|
56
|
+
// val event = Arguments.createMap().apply {
|
|
57
|
+
// putString("data", it.toString())
|
|
58
|
+
// putString("message", "QOREID SDK INITIALIZED")
|
|
59
|
+
// putString("event", "SESSION_RESULT")
|
|
60
|
+
// }
|
|
61
|
+
//
|
|
62
|
+
// sendEvent(reactContext, "onResult", event)
|
|
63
|
+
// }
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
override fun getName(): String {
|
|
@@ -60,56 +68,56 @@ class QoreidSdkModule(val reactContext: ReactApplicationContext) :
|
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
@ReactMethod
|
|
63
|
-
fun
|
|
71
|
+
fun launchQoreidSdk(readableData: ReadableMap) {
|
|
72
|
+
val data = readableData.toHashMap()
|
|
64
73
|
|
|
65
74
|
if (currentActivity == null) {
|
|
66
75
|
Log.e("Error", "No current activity");
|
|
67
76
|
return
|
|
68
77
|
}
|
|
69
78
|
|
|
70
|
-
val
|
|
71
|
-
val
|
|
72
|
-
|
|
73
|
-
val config = qoreIdJSData.config
|
|
74
|
-
val apD = qoreIdJSData.applicantData
|
|
79
|
+
val config = data?.get("config") as? HashMap<*, *>
|
|
80
|
+
val apD = data?.get("applicantData") as? HashMap<*, *>
|
|
75
81
|
val applicantData = ApplicantData(
|
|
76
|
-
apD
|
|
77
|
-
apD
|
|
78
|
-
apD
|
|
79
|
-
apD
|
|
80
|
-
apD
|
|
81
|
-
apD
|
|
82
|
-
apD.gender
|
|
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("gender") as String?
|
|
83
88
|
)
|
|
84
89
|
|
|
85
|
-
|
|
90
|
+
|
|
91
|
+
val adD = data?.get("addressData") as? HashMap<*, *>
|
|
86
92
|
val addressData = AddressData(
|
|
87
|
-
adD
|
|
88
|
-
adD
|
|
89
|
-
adD
|
|
90
|
-
adD
|
|
93
|
+
adD?.get("address") as String?,
|
|
94
|
+
adD?.get("city") as String?,
|
|
95
|
+
adD?.get("lga") as String?,
|
|
96
|
+
adD?.get("state") as String?,
|
|
91
97
|
)
|
|
98
|
+
val flowId = config?.get("flowId") as? Double
|
|
92
99
|
|
|
93
|
-
val qoreIDParams = if (
|
|
100
|
+
val qoreIDParams = if (flowId?.toLong() != 0L) {
|
|
94
101
|
QoreIDParams()
|
|
95
|
-
.clientId(config
|
|
96
|
-
.customerReference(
|
|
102
|
+
.clientId(config?.get("clientId") as String)
|
|
103
|
+
.customerReference(config?.get("customerReference") as String)
|
|
97
104
|
.inputData(applicantData, addressData)
|
|
98
|
-
.ocrAcceptedDocuments(
|
|
99
|
-
.workflow(
|
|
100
|
-
|
|
105
|
+
.ocrAcceptedDocuments(data?.get("acceptedDocuments") as List<String>)
|
|
106
|
+
.workflow(flowId!!.toLong())
|
|
107
|
+
// .workflowDefaultIdentity(config?.get("defaultIdType") as String)
|
|
101
108
|
} else {
|
|
102
109
|
QoreIDParams()
|
|
103
|
-
.clientId(config
|
|
104
|
-
.customerReference(
|
|
110
|
+
.clientId(config?.get("clientId") as String)
|
|
111
|
+
.customerReference(config?.get("customerReference") as String)
|
|
105
112
|
.inputData(applicantData, addressData)
|
|
106
|
-
.ocrAcceptedDocuments(
|
|
107
|
-
.collection(config
|
|
113
|
+
.ocrAcceptedDocuments(data?.get("acceptedDocuments") as List<String>)
|
|
114
|
+
.collection(config?.get("productCode") as String)
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
QoreIDSdk.s(BuildConfig.s);
|
|
111
118
|
QoreIDSdk.params(qoreIDParams)
|
|
112
119
|
QoreIDSdk.launch(requireNotNull(currentActivity))
|
|
120
|
+
|
|
113
121
|
}
|
|
114
122
|
|
|
115
123
|
fun processQoreIDResult(context: ReactContext, qoreIdResult: QoreIDResult) {
|
|
@@ -120,16 +128,19 @@ class QoreidSdkModule(val reactContext: ReactApplicationContext) :
|
|
|
120
128
|
putString("code", qoreIdResult.code.toString())
|
|
121
129
|
putString("data", qoreIdResult.data.toString())
|
|
122
130
|
putString("message", qoreIdResult.message)
|
|
131
|
+
putString("event", "ERROR_RESULT")
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
sendEvent(context, "onResult", event)
|
|
126
135
|
|
|
127
136
|
}
|
|
137
|
+
|
|
128
138
|
is SuccessResult -> {
|
|
129
139
|
// Handle success.
|
|
130
140
|
val event = Arguments.createMap().apply {
|
|
131
141
|
putString("data", qoreIdResult.data.toString())
|
|
132
142
|
putString("message", qoreIdResult.message)
|
|
143
|
+
putString("event", "SUCCESS_RESULT")
|
|
133
144
|
}
|
|
134
145
|
|
|
135
146
|
sendEvent(context, "onResult", event)
|
package/ios/QoreidSdk.m
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@interface RCT_EXTERN_MODULE(QoreidSdk, NSObject)
|
|
7
|
+
|
|
8
|
+
RCT_EXTERN_METHOD (launchQoreidSdk: (NSDictionary *) data)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
// Don't compile this code when we build for the old architecture.
|
|
12
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
13
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
14
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
15
|
+
{
|
|
16
|
+
return std::make_shared<facebook::react::NativeQoreidSdkSpecJSI>(params);
|
|
17
|
+
}
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
@end
|
|
21
|
+
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
//
|
|
2
|
+
// QoreidSdk.swift
|
|
3
|
+
// QoreidSdk
|
|
4
|
+
//
|
|
5
|
+
// Created by Emmanuel Ugwuoke on 29/09/2023.
|
|
6
|
+
// Copyright © 2023 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
import React
|
|
11
|
+
import UIKit
|
|
12
|
+
import QoreIDSDK
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@objc(QoreidSdk)
|
|
16
|
+
class QoreidSdk: RCTEventEmitter {
|
|
17
|
+
|
|
18
|
+
@objc func launchQoreidSdk(_ data: NSDictionary) -> Void {
|
|
19
|
+
let config = data["config"] as? NSDictionary
|
|
20
|
+
let _applicant = data["applicantData"] as? NSDictionary
|
|
21
|
+
let _identity = data["identityData"] as? NSDictionary
|
|
22
|
+
let _address = data["addressData"] as? NSDictionary
|
|
23
|
+
let ocrs = data["acceptedDocuments"] as? NSArray
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
let applicant = ApplicantData(
|
|
27
|
+
firstname:_applicant?["firstName"] as? String,
|
|
28
|
+
lastname:_applicant?["lastName"] as? String,
|
|
29
|
+
phone: _applicant?["phoneNumber"] as? String,
|
|
30
|
+
middlename: _applicant?["middleName"] as? String
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
let addressData = AddressData(
|
|
34
|
+
address: _address?["address"] as? String,
|
|
35
|
+
city: _address?["city"] as? String,
|
|
36
|
+
lga: _address?["lga"] as? String,
|
|
37
|
+
state: _address?["state"] as? String,
|
|
38
|
+
county: _address?["country"] as? String,
|
|
39
|
+
subCounty: _address?["region"] as? String,
|
|
40
|
+
ccc: _address?["ccc"] as? String ?? ""
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
let identityData = IdentityData(
|
|
44
|
+
idType: _identity?["idType"] as? String,
|
|
45
|
+
idNumber: _identity?["idNumber"] as? String
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
var param:QoreIDParam?
|
|
49
|
+
|
|
50
|
+
if (config!["flowId"] as! Int != 0) {
|
|
51
|
+
param = QoreIDParam()
|
|
52
|
+
.clientId(clientId: config?["clientId"] as? String)
|
|
53
|
+
.customerReference(config?["customerReference"] as? String)
|
|
54
|
+
.inputData(InputData(applicant: applicant,address: addressData, identity: identityData))
|
|
55
|
+
.ocrAcceptedDocuments(ocrs as? Array<String>)
|
|
56
|
+
.workFlow(config!["flowId"] as! Int)
|
|
57
|
+
.workFlowRequiredIdentity(config?["defaultIdType"] as? String ?? "")
|
|
58
|
+
.build()
|
|
59
|
+
} else {
|
|
60
|
+
param = QoreIDParam()
|
|
61
|
+
.clientId(clientId: config?["clientId"] as? String)
|
|
62
|
+
.customerReference(config?["customerReference"] as? String)
|
|
63
|
+
.inputData(InputData(applicant: applicant,address: addressData, identity: identityData))
|
|
64
|
+
.ocrAcceptedDocuments(ocrs as? Array<String>)
|
|
65
|
+
.collection((config?["productCode"] as? String)!)
|
|
66
|
+
.build()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if let params = param {
|
|
70
|
+
DispatchQueue.main.async {
|
|
71
|
+
let vc = ViewController()
|
|
72
|
+
vc.param = param
|
|
73
|
+
vc.onQoreIdResult = { [weak self] result in
|
|
74
|
+
self?.onQoreIdResultReceived(result: result)
|
|
75
|
+
}
|
|
76
|
+
self.controller().pushViewController(vc, animated: false)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
func onQoreIdResultReceived(result: QoreIDResult?) {
|
|
82
|
+
if let result = result {
|
|
83
|
+
if let errorResult = result as? ErrorResult {
|
|
84
|
+
self.sendEvent(withName: "onResult", body:["code": String(describing: errorResult.code), "data": self.parseData(errorResult.data), "message": errorResult.message, "event": "ERROR_RESULT"])
|
|
85
|
+
self.controller().popViewController(animated: false)
|
|
86
|
+
} else if let successResult = result as? SuccessResult {
|
|
87
|
+
self.sendEvent(withName: "onResult", body:["data": self.parseData( successResult.data), "message": successResult.message!, "event": "SUCCESS_RESULT"])
|
|
88
|
+
self.controller().popViewController(animated: false)
|
|
89
|
+
} else if let pendingResult = result as? PendingResult {
|
|
90
|
+
self.sendEvent(withName: "onResult", body:["data": pendingResult.data?.verification?.id! ?? 0, "message": pendingResult.message!, "event": "SESSION_RESULT"])
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
func parseData(_ resultData: QoreIDSDK.ResultData?) -> [String: Any] {
|
|
96
|
+
var data: [String: Any] = [:]
|
|
97
|
+
|
|
98
|
+
if let resultData = resultData {
|
|
99
|
+
data["customerReference"] = resultData.customerReference ?? ""
|
|
100
|
+
|
|
101
|
+
data["flowId"] = String(resultData.flowId ?? 0)
|
|
102
|
+
|
|
103
|
+
var verificationData: [String: Any] = [:]
|
|
104
|
+
|
|
105
|
+
verificationData["id"] = resultData.verification?.id
|
|
106
|
+
|
|
107
|
+
verificationData["status"] = [
|
|
108
|
+
"status": resultData.verification?.status?.status ?? "",
|
|
109
|
+
"state": resultData.verification?.status?.state ?? ""
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
data["verification"] = verificationData
|
|
113
|
+
|
|
114
|
+
data["productCode"] = resultData.productCode
|
|
115
|
+
|
|
116
|
+
} else {
|
|
117
|
+
data = [:]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return data
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
override func supportedEvents() -> [String] {
|
|
124
|
+
return ["onResult"]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@objc override static func requiresMainQueueSetup() -> Bool {
|
|
128
|
+
return false
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private func controller() -> UINavigationController {
|
|
132
|
+
let rootViewController = UIApplication.shared.keyWindow?.rootViewController
|
|
133
|
+
return rootViewController as! UINavigationController
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
objects = {
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
|
-
|
|
10
|
+
2A18B1372AC6CA26005CB836 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A18B1362AC6CA26005CB836 /* File.swift */; };
|
|
11
11
|
/* End PBXBuildFile section */
|
|
12
12
|
|
|
13
13
|
/* Begin PBXCopyFilesBuildPhase section */
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
|
|
25
25
|
/* Begin PBXFileReference section */
|
|
26
26
|
134814201AA4EA6300B7C361 /* libQoreidSdk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libQoreidSdk.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
27
|
+
2A18B1352AC6CA25005CB836 /* QoreidSdk-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "QoreidSdk-Bridging-Header.h"; sourceTree = "<group>"; };
|
|
28
|
+
2A18B1362AC6CA26005CB836 /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
|
|
27
29
|
B3E7B5881CC2AC0600A0062D /* QoreidSdk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QoreidSdk.h; sourceTree = "<group>"; };
|
|
28
30
|
B3E7B5891CC2AC0600A0062D /* QoreidSdk.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QoreidSdk.m; sourceTree = "<group>"; };
|
|
29
31
|
/* End PBXFileReference section */
|
|
@@ -50,9 +52,11 @@
|
|
|
50
52
|
58B511D21A9E6C8500147676 = {
|
|
51
53
|
isa = PBXGroup;
|
|
52
54
|
children = (
|
|
55
|
+
2A18B1362AC6CA26005CB836 /* File.swift */,
|
|
53
56
|
B3E7B5881CC2AC0600A0062D /* QoreidSdk.h */,
|
|
54
57
|
B3E7B5891CC2AC0600A0062D /* QoreidSdk.m */,
|
|
55
58
|
134814211AA4EA7D00B7C361 /* Products */,
|
|
59
|
+
2A18B1352AC6CA25005CB836 /* QoreidSdk-Bridging-Header.h */,
|
|
56
60
|
);
|
|
57
61
|
sourceTree = "<group>";
|
|
58
62
|
};
|
|
@@ -87,6 +91,7 @@
|
|
|
87
91
|
TargetAttributes = {
|
|
88
92
|
58B511DA1A9E6C8500147676 = {
|
|
89
93
|
CreatedOnToolsVersion = 6.1.1;
|
|
94
|
+
LastSwiftMigration = 1500;
|
|
90
95
|
};
|
|
91
96
|
};
|
|
92
97
|
};
|
|
@@ -113,7 +118,7 @@
|
|
|
113
118
|
isa = PBXSourcesBuildPhase;
|
|
114
119
|
buildActionMask = 2147483647;
|
|
115
120
|
files = (
|
|
116
|
-
|
|
121
|
+
2A18B1372AC6CA26005CB836 /* File.swift in Sources */,
|
|
117
122
|
);
|
|
118
123
|
runOnlyForDeploymentPostprocessing = 0;
|
|
119
124
|
};
|
|
@@ -218,6 +223,7 @@
|
|
|
218
223
|
58B511F01A9E6C8500147676 /* Debug */ = {
|
|
219
224
|
isa = XCBuildConfiguration;
|
|
220
225
|
buildSettings = {
|
|
226
|
+
CLANG_ENABLE_MODULES = YES;
|
|
221
227
|
HEADER_SEARCH_PATHS = (
|
|
222
228
|
"$(inherited)",
|
|
223
229
|
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
@@ -225,15 +231,22 @@
|
|
|
225
231
|
"$(SRCROOT)/../../react-native/React/**",
|
|
226
232
|
);
|
|
227
233
|
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
228
|
-
OTHER_LDFLAGS =
|
|
234
|
+
OTHER_LDFLAGS = (
|
|
235
|
+
"-ObjC",
|
|
236
|
+
"$(inherit)",
|
|
237
|
+
);
|
|
229
238
|
PRODUCT_NAME = QoreidSdk;
|
|
230
239
|
SKIP_INSTALL = YES;
|
|
240
|
+
SWIFT_OBJC_BRIDGING_HEADER = "QoreidSdk-Bridging-Header.h";
|
|
241
|
+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
|
242
|
+
SWIFT_VERSION = 5.0;
|
|
231
243
|
};
|
|
232
244
|
name = Debug;
|
|
233
245
|
};
|
|
234
246
|
58B511F11A9E6C8500147676 /* Release */ = {
|
|
235
247
|
isa = XCBuildConfiguration;
|
|
236
248
|
buildSettings = {
|
|
249
|
+
CLANG_ENABLE_MODULES = YES;
|
|
237
250
|
HEADER_SEARCH_PATHS = (
|
|
238
251
|
"$(inherited)",
|
|
239
252
|
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
@@ -241,9 +254,14 @@
|
|
|
241
254
|
"$(SRCROOT)/../../react-native/React/**",
|
|
242
255
|
);
|
|
243
256
|
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
244
|
-
OTHER_LDFLAGS =
|
|
257
|
+
OTHER_LDFLAGS = (
|
|
258
|
+
"-ObjC",
|
|
259
|
+
"$(inherit)",
|
|
260
|
+
);
|
|
245
261
|
PRODUCT_NAME = QoreidSdk;
|
|
246
262
|
SKIP_INSTALL = YES;
|
|
263
|
+
SWIFT_OBJC_BRIDGING_HEADER = "QoreidSdk-Bridging-Header.h";
|
|
264
|
+
SWIFT_VERSION = 5.0;
|
|
247
265
|
};
|
|
248
266
|
name = Release;
|
|
249
267
|
};
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>BuildLocationStyle</key>
|
|
6
|
+
<string>UseAppPreferences</string>
|
|
7
|
+
<key>CustomBuildLocationType</key>
|
|
8
|
+
<string>RelativeToDerivedData</string>
|
|
9
|
+
<key>DerivedDataLocationStyle</key>
|
|
10
|
+
<string>Default</string>
|
|
11
|
+
<key>ShowSharedSchemesAutomaticallyEnabled</key>
|
|
12
|
+
<true/>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|