dojah-kyc-sdk-react-expo 0.1.1 → 0.1.3
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 +46 -51
- package/app.json +5 -0
- package/build/DojahKycSdkReactExpoModule.d.ts.map +1 -1
- package/build/DojahKycSdkReactExpoModule.js.map +1 -1
- package/expo-module.config.json +15 -4
- package/ios/DojahKycScreenDelegate.swift +8 -0
- package/ios/DojahKycSdkReactExpo.podspec +2 -0
- package/ios/DojahKycSdkReactExpoModule.swift +224 -14
- package/package.json +6 -4
- package/plugin/withDojahKyc.js +109 -1
- package/src/DojahKycSdkReactExpoModule.ts +3 -3
package/README.md
CHANGED
|
@@ -6,67 +6,62 @@
|
|
|
6
6
|
npm install dojah-kyc-sdk-react-expo
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
## Setup
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
### Install expo-build-properties if you don't have it
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* Supported targetSdkVersion - 35
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Enable jetifier in grade.properties:
|
|
18
|
-
```
|
|
19
|
-
android.enableJetifier=true
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Permissions
|
|
23
|
-
|
|
24
|
-
For Android you don't need to declare permissions, its already included in the Package.
|
|
25
|
-
|
|
26
|
-
## IOS Setup
|
|
27
|
-
|
|
28
|
-
### Requirements
|
|
29
|
-
|
|
30
|
-
* Minimum iOS version - 14
|
|
31
|
-
|
|
32
|
-
### Add the following POD dependencies in your Podfile app under your App target
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
pod 'Realm', '~> 10.52.2', :modular_headers => true
|
|
36
|
-
pod 'DojahWidget', :git => 'https://github.com/dojah-inc/sdk-swift.git', :branch => 'pod-package'
|
|
13
|
+
```sh
|
|
14
|
+
npx expo install expo-build-properties
|
|
37
15
|
```
|
|
38
16
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
17
|
+
### Add the following plugins and permissions in your app.json
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"expo": {
|
|
21
|
+
...
|
|
22
|
+
"ios": {
|
|
23
|
+
"infoPlist": {
|
|
24
|
+
"NSLocationWhenInUseUsageDescription": "This app uses location services to provide a better experience.",
|
|
25
|
+
"NSLocationAlwaysUsageDescription": "This app uses location services to provide a better experience.",
|
|
26
|
+
"NSLocationUsageDescription": "This app uses location services to provide a better experience.",
|
|
27
|
+
"NSPhotoLibraryUsageDescription": "This app uses the photo library to provide a better experience.",
|
|
28
|
+
"NSCameraUsageDescription": "This app uses the camera to provide a better experience.",
|
|
29
|
+
"NSMicrophoneUsageDescription": "This app uses the microphone to provide a better experience."
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"plugins": [
|
|
33
|
+
...
|
|
34
|
+
"dojah-kyc-sdk-react-expo",
|
|
35
|
+
[
|
|
36
|
+
"expo-build-properties",
|
|
37
|
+
{
|
|
38
|
+
"ios": {
|
|
39
|
+
"extraPods": [
|
|
40
|
+
{
|
|
41
|
+
"name": "Realm",
|
|
42
|
+
"version": "~> 10.52.2",
|
|
43
|
+
"modular_headers": true
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "DojahWidget",
|
|
47
|
+
"git": "https://github.com/dojah-inc/sdk-swift.git",
|
|
48
|
+
"branch": "pod-package"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
48
57
|
```
|
|
49
58
|
|
|
50
|
-
|
|
59
|
+
### Run prebuild:
|
|
51
60
|
|
|
52
61
|
```sh
|
|
53
|
-
|
|
54
|
-
pod install
|
|
62
|
+
npx expo prebuild
|
|
55
63
|
```
|
|
56
64
|
|
|
57
|
-
### Permissions
|
|
58
|
-
|
|
59
|
-
For IOS, Add the following keys to your Info.plist file:
|
|
60
|
-
|
|
61
|
-
NSCameraUsageDescription - describe why your app needs access to the camera. This is called
|
|
62
|
-
Privacy - Camera Usage Description in the visual editor.
|
|
63
|
-
|
|
64
|
-
NSMicrophoneUsageDescription - describe why your app needs access to the microphone, if you intend
|
|
65
|
-
to record videos. This is called Privacy - Microphone Usage Description in the visual editor.
|
|
66
|
-
|
|
67
|
-
NSLocationWhenInUseUsageDescription - describe why your app needs access to the location, if you
|
|
68
|
-
intend to verify address/location. This is called Privacy - Location Usage Description in the visual
|
|
69
|
-
editor.
|
|
70
65
|
|
|
71
66
|
## Usage
|
|
72
67
|
|
package/app.json
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DojahKycSdkReactExpoModule.d.ts","sourceRoot":"","sources":["../src/DojahKycSdkReactExpoModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAEhF,OAAO,OAAO,WAAY,SAAQ,YAAY,CAAC,gCAAgC,CAAC;IAC9E,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"DojahKycSdkReactExpoModule.d.ts","sourceRoot":"","sources":["../src/DojahKycSdkReactExpoModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAEhF,OAAO,OAAO,WAAY,SAAQ,YAAY,CAAC,gCAAgC,CAAC;IAC9E,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,EAClD,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,EACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GACrC,OAAO,CAAC,MAAM,CAAC;CACnB;;AAGD,wBAA+D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DojahKycSdkReactExpoModule.js","sourceRoot":"","sources":["../src/DojahKycSdkReactExpoModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAWzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAc,aAAa,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from 'expo';\n\nimport { DojahKycSdkReactExpoModuleEvents } from './DojahKycSdkReactExpo.types';\n\ndeclare class DojahKycSdk extends NativeModule<DojahKycSdkReactExpoModuleEvents> {\n launch(widgetId: string, referenceId?: string | null,\n
|
|
1
|
+
{"version":3,"file":"DojahKycSdkReactExpoModule.js","sourceRoot":"","sources":["../src/DojahKycSdkReactExpoModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAWzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAc,aAAa,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from 'expo';\n\nimport { DojahKycSdkReactExpoModuleEvents } from './DojahKycSdkReactExpo.types';\n\ndeclare class DojahKycSdk extends NativeModule<DojahKycSdkReactExpoModuleEvents> {\n launch(widgetId: string, referenceId?: string | null,\n email?: string | null,\n extraData?: Record<string, any> | null\n ): Promise<string>;\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<DojahKycSdk>('DojahKycSdk');\n"]}
|
package/expo-module.config.json
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"platforms": [
|
|
2
|
+
"platforms": [
|
|
3
|
+
"apple",
|
|
4
|
+
"android",
|
|
5
|
+
"web"
|
|
6
|
+
],
|
|
3
7
|
"apple": {
|
|
4
|
-
"modules": [
|
|
8
|
+
"modules": [
|
|
9
|
+
"DojahKycSdkReactExpoModule"
|
|
10
|
+
],
|
|
11
|
+
"appDelegateSubscribers": [
|
|
12
|
+
"DojahKycScreenDelegate"
|
|
13
|
+
]
|
|
5
14
|
},
|
|
6
15
|
"android": {
|
|
7
|
-
"modules": [
|
|
16
|
+
"modules": [
|
|
17
|
+
"com.dojah.dojah_Kyc_rn_expo.DojahKycSdkReactExpoModule"
|
|
18
|
+
]
|
|
8
19
|
}
|
|
9
|
-
}
|
|
20
|
+
}
|
|
@@ -1,25 +1,91 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
|
+
import DojahWidget
|
|
3
|
+
|
|
4
|
+
class DojahNavigationControllerDelegate: NSObject, UINavigationControllerDelegate {
|
|
5
|
+
var onDidShow: (UIViewController) -> Void = { _ in }
|
|
6
|
+
func navigationController(_ navigationController: UINavigationController,
|
|
7
|
+
didShow viewController: UIViewController,
|
|
8
|
+
animated: Bool) {
|
|
9
|
+
print("Did show: \(viewController)")
|
|
10
|
+
onDidShow(viewController)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func navigationController(_ navigationController: UINavigationController,
|
|
14
|
+
willShow viewController: UIViewController,
|
|
15
|
+
animated: Bool) {
|
|
16
|
+
print("Will show: \(viewController)")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
func setOnDidShow(_ onDidShow: @escaping (UIViewController) -> Void) {
|
|
20
|
+
self.onDidShow = onDidShow
|
|
21
|
+
}
|
|
22
|
+
}
|
|
2
23
|
|
|
3
24
|
public class DojahKycSdkReactExpoModule: Module {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
25
|
+
|
|
26
|
+
var mPromise:Promise? = nil
|
|
27
|
+
|
|
28
|
+
let navDelegate = DojahNavigationControllerDelegate()
|
|
29
|
+
|
|
30
|
+
let navCtrl = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController
|
|
31
|
+
|
|
32
|
+
var prevController:UIViewController? = nil
|
|
33
|
+
|
|
34
|
+
required public init(appContext: AppContext) {
|
|
35
|
+
super.init(appContext: appContext)
|
|
36
|
+
navDelegate.setOnDidShow { vc in
|
|
37
|
+
print("onDidShow: \(vc)")
|
|
38
|
+
//return result from DojahWidget once verification
|
|
39
|
+
//is done,failed or cancel
|
|
40
|
+
if(!String(describing:vc).contains("DojahWidget")){
|
|
41
|
+
let vStatus = DojahWidgetSDK.getVerificationResultStatus()
|
|
42
|
+
let status = if(vStatus.isEmpty){ "closed"} else {vStatus}
|
|
43
|
+
self.mPromise?.resolve(status)
|
|
44
|
+
self.prevController = nil
|
|
45
|
+
}else if(String(describing:vc).contains("DojahWidget.DJDisclaimer")
|
|
46
|
+
&& self.prevController != nil){
|
|
47
|
+
self.navCtrl?.popToRootViewController(animated: false)
|
|
48
|
+
}else if(!String(describing:vc).contains("DojahWidget.SDKInitViewController")){
|
|
49
|
+
self.prevController = vc
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if navCtrl != nil {
|
|
54
|
+
navCtrl!.delegate = navDelegate
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
7
58
|
public func definition() -> ModuleDefinition {
|
|
8
|
-
|
|
9
|
-
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
10
|
-
// The module will be accessible from `requireNativeModule('DojahKycSdk')` in JavaScript.
|
|
59
|
+
|
|
11
60
|
Name("DojahKycSdk")
|
|
12
61
|
|
|
13
|
-
// Defines event names that the module can send to JavaScript.
|
|
14
62
|
Events("onChange")
|
|
15
63
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
64
|
+
AsyncFunction("launch") { (widgetId: String, referenceId: String?, email: String?, extraData: ExtraDataRecord?,promise:Promise) in
|
|
65
|
+
mPromise = promise
|
|
66
|
+
|
|
67
|
+
let navController = navCtrl
|
|
68
|
+
|
|
69
|
+
print("nav ctrl: $\(String(describing: navController))")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if(navController == nil){
|
|
73
|
+
self.mPromise?.reject("002","failed to initialize, can't find navController")
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
DispatchQueue.main.async {
|
|
78
|
+
do{
|
|
79
|
+
DojahWidgetSDK.initialize(
|
|
80
|
+
widgetID: widgetId,
|
|
81
|
+
referenceID: referenceId,
|
|
82
|
+
emailAddress: email,
|
|
83
|
+
extraUserData: extraData?.toExtraUserData(),
|
|
84
|
+
navController: navController!)
|
|
85
|
+
}catch{
|
|
86
|
+
self.mPromise?.reject("001","failed to initialize")
|
|
87
|
+
}
|
|
88
|
+
}
|
|
23
89
|
}
|
|
24
90
|
|
|
25
91
|
// Enables the module to be used as a native view. Definition components that are accepted as part of the
|
|
@@ -36,3 +102,147 @@ public class DojahKycSdkReactExpoModule: Module {
|
|
|
36
102
|
}
|
|
37
103
|
}
|
|
38
104
|
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
struct ExtraDataRecord : Record {
|
|
109
|
+
@Field
|
|
110
|
+
var userData: UserRecord? = nil
|
|
111
|
+
|
|
112
|
+
@Field
|
|
113
|
+
var govData: GovDataRecord? = nil
|
|
114
|
+
|
|
115
|
+
@Field
|
|
116
|
+
var govId: GovIdRecord? = nil
|
|
117
|
+
|
|
118
|
+
@Field
|
|
119
|
+
var location: LocationRecord? = nil
|
|
120
|
+
|
|
121
|
+
@Field
|
|
122
|
+
var businessData: BusinessDataRecord? = nil
|
|
123
|
+
|
|
124
|
+
@Field
|
|
125
|
+
var address: String? = nil
|
|
126
|
+
|
|
127
|
+
@Field
|
|
128
|
+
var metadata: [String:Any]? = nil
|
|
129
|
+
|
|
130
|
+
func toExtraUserData()-> ExtraUserData {
|
|
131
|
+
return ExtraUserData(
|
|
132
|
+
userData: userData?.toUserData(),
|
|
133
|
+
govData: govData?.toGovData(),
|
|
134
|
+
govId: govId?.toGovId(),
|
|
135
|
+
location: location?.toLocation(),
|
|
136
|
+
businessData: businessData?.toBusinessData(),
|
|
137
|
+
address: address,
|
|
138
|
+
metadata: metadata
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
struct UserRecord : Record {
|
|
146
|
+
@Field
|
|
147
|
+
var firstName: String? = nil
|
|
148
|
+
|
|
149
|
+
@Field
|
|
150
|
+
var lastName: String? = nil
|
|
151
|
+
|
|
152
|
+
@Field
|
|
153
|
+
var dob: String? = nil
|
|
154
|
+
|
|
155
|
+
@Field
|
|
156
|
+
var email: String? = nil
|
|
157
|
+
|
|
158
|
+
func toUserData()-> UserBioData {
|
|
159
|
+
return UserBioData(
|
|
160
|
+
firstName: firstName,
|
|
161
|
+
lastName: lastName,
|
|
162
|
+
dob: dob,
|
|
163
|
+
email: email
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
struct GovDataRecord : Record {
|
|
169
|
+
|
|
170
|
+
@Field
|
|
171
|
+
var bvn: String? = nil
|
|
172
|
+
|
|
173
|
+
@Field
|
|
174
|
+
var dl: String? = nil
|
|
175
|
+
|
|
176
|
+
@Field
|
|
177
|
+
var nin: String? = nil
|
|
178
|
+
|
|
179
|
+
@Field
|
|
180
|
+
var vnin: String? = nil
|
|
181
|
+
|
|
182
|
+
func toGovData()-> ExtraGovData {
|
|
183
|
+
return ExtraGovData(
|
|
184
|
+
bvn: bvn,
|
|
185
|
+
dl: dl,
|
|
186
|
+
nin: nin,
|
|
187
|
+
vnin: vnin
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
struct GovIdRecord : Record {
|
|
193
|
+
@Field
|
|
194
|
+
var national: String? = nil
|
|
195
|
+
|
|
196
|
+
@Field
|
|
197
|
+
var passport: String? = nil
|
|
198
|
+
|
|
199
|
+
@Field
|
|
200
|
+
var dl: String? = nil
|
|
201
|
+
|
|
202
|
+
@Field
|
|
203
|
+
var voter: String? = nil
|
|
204
|
+
|
|
205
|
+
@Field
|
|
206
|
+
var nin: String? = nil
|
|
207
|
+
|
|
208
|
+
@Field
|
|
209
|
+
var others: String? = nil
|
|
210
|
+
|
|
211
|
+
func toGovId()-> ExtraGovIdData {
|
|
212
|
+
return ExtraGovIdData(
|
|
213
|
+
national: national,
|
|
214
|
+
passport: passport,
|
|
215
|
+
dl: dl,
|
|
216
|
+
voter: voter,
|
|
217
|
+
nin: nin,
|
|
218
|
+
others: others
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
struct LocationRecord : Record {
|
|
224
|
+
@Field
|
|
225
|
+
var latitude: String? = nil
|
|
226
|
+
|
|
227
|
+
@Field
|
|
228
|
+
var longitude: String? = nil
|
|
229
|
+
|
|
230
|
+
func toLocation()-> ExtraLocationData {
|
|
231
|
+
return ExtraLocationData(
|
|
232
|
+
longitude: longitude,
|
|
233
|
+
latitude: latitude
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
struct BusinessDataRecord : Record {
|
|
239
|
+
@Field
|
|
240
|
+
var cac: String? = nil
|
|
241
|
+
|
|
242
|
+
func toBusinessData()-> ExtraBusinessData {
|
|
243
|
+
return ExtraBusinessData(
|
|
244
|
+
cac: cac
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dojah-kyc-sdk-react-expo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Dojah Kyc",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
7
|
-
|
|
7
|
+
"expo": {
|
|
8
8
|
"plugins": [
|
|
9
9
|
"./app.plugin.js"
|
|
10
10
|
]
|
|
@@ -33,16 +33,18 @@
|
|
|
33
33
|
"author": "dojah-inc < dojah-inc@dojah.io> (https://github.com/dojah-inc)",
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"homepage": "https://github.com/dojah-inc/dojah_kyc_sdk_rn_expo#readme",
|
|
36
|
-
"dependencies": {},
|
|
37
36
|
"devDependencies": {
|
|
38
37
|
"@types/react": "~19.0.0",
|
|
39
|
-
"expo-module-scripts": "^4.1.6",
|
|
40
38
|
"expo": "~53.0.0",
|
|
39
|
+
"expo-module-scripts": "^4.1.6",
|
|
41
40
|
"react-native": "0.79.1"
|
|
42
41
|
},
|
|
43
42
|
"peerDependencies": {
|
|
44
43
|
"expo": "*",
|
|
45
44
|
"react": "*",
|
|
46
45
|
"react-native": "*"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"expo-build-properties": "~0.14.6"
|
|
47
49
|
}
|
|
48
50
|
}
|
package/plugin/withDojahKyc.js
CHANGED
|
@@ -3,17 +3,23 @@ const {
|
|
|
3
3
|
withAppBuildGradle,
|
|
4
4
|
withSettingsGradle,
|
|
5
5
|
withGradleProperties,
|
|
6
|
+
withAppDelegate,
|
|
7
|
+
WarningAggregator,
|
|
6
8
|
} = require('@expo/config-plugins');
|
|
9
|
+
|
|
7
10
|
const path = require('path');
|
|
8
11
|
|
|
9
12
|
const withDojahKyc = config => {
|
|
10
13
|
return withPlugins(config, [
|
|
11
14
|
// withAppBuildGradleModification,
|
|
12
15
|
// withSettingsGradleModification,
|
|
13
|
-
|
|
16
|
+
withGradlePropertiesModification,
|
|
17
|
+
withCustomSwiftAppDelegateRootView,
|
|
18
|
+
withCustomObjcAppDelegateRootView,
|
|
14
19
|
]);
|
|
15
20
|
};
|
|
16
21
|
|
|
22
|
+
|
|
17
23
|
function withAppBuildGradleModification(config) {
|
|
18
24
|
return withAppBuildGradle(config, config => {
|
|
19
25
|
if (!config.modResults.contents.includes("project(':dojah_Kyc_rn_expo')")) {
|
|
@@ -41,6 +47,7 @@ function withSettingsGradleModification(config) {
|
|
|
41
47
|
|
|
42
48
|
function withGradlePropertiesModification(config) {
|
|
43
49
|
return withGradleProperties(config, (config) => {
|
|
50
|
+
|
|
44
51
|
if (!config.modResults) {
|
|
45
52
|
config.modResults = [];
|
|
46
53
|
}
|
|
@@ -60,5 +67,106 @@ function withGradlePropertiesModification(config) {
|
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
|
|
70
|
+
const CUSTOM_CREATE_ROOT_VIEW = `
|
|
71
|
+
override func createRootViewController() -> UIViewController {
|
|
72
|
+
let rootVC = UIViewController()
|
|
73
|
+
let nav = UINavigationController(rootViewController: rootVC)
|
|
74
|
+
return nav
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
override func setRootView(_ rootView: UIView, toRootViewController rootViewController: UIViewController) {
|
|
78
|
+
if let nav = rootViewController as? UINavigationController,
|
|
79
|
+
let firstVC = nav.viewControllers.first {
|
|
80
|
+
firstVC.view = rootView
|
|
81
|
+
} else {
|
|
82
|
+
rootViewController.view = rootView
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
const withCustomSwiftAppDelegateRootView = config => {
|
|
88
|
+
return withAppDelegate(config, config => {
|
|
89
|
+
const contents = config.modResults.contents;
|
|
90
|
+
|
|
91
|
+
const classStart = contents.indexOf("class ReactNativeDelegate");
|
|
92
|
+
if (classStart === -1) {
|
|
93
|
+
WarningAggregator.addWarningIOS(
|
|
94
|
+
"withCustomRootView",
|
|
95
|
+
"`ReactNativeDelegate` not found in AppDelegate.swift"
|
|
96
|
+
);
|
|
97
|
+
return config;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const insertionPoint = contents.indexOf("{", classStart) + 1;
|
|
101
|
+
|
|
102
|
+
const newContents =
|
|
103
|
+
contents.slice(0, insertionPoint) +
|
|
104
|
+
"\n" +
|
|
105
|
+
CUSTOM_CREATE_ROOT_VIEW +
|
|
106
|
+
"\n" +
|
|
107
|
+
contents.slice(insertionPoint);
|
|
108
|
+
|
|
109
|
+
config.modResults.contents = newContents;
|
|
110
|
+
|
|
111
|
+
return config;
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const NAV_CONTROLLER_SETUP = `
|
|
116
|
+
// Injected by withObjcNavigationRoot config plugin
|
|
117
|
+
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
|
|
118
|
+
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
|
|
119
|
+
moduleName:@"main"
|
|
120
|
+
initialProperties:nil];
|
|
121
|
+
|
|
122
|
+
UIViewController *rootViewController = [UIViewController new];
|
|
123
|
+
rootViewController.view = rootView;
|
|
124
|
+
|
|
125
|
+
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
|
|
126
|
+
|
|
127
|
+
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
128
|
+
self.window.rootViewController = navigationController;
|
|
129
|
+
[self.window makeKeyAndVisible];
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
const withCustomObjcAppDelegateRootView = config => {
|
|
133
|
+
return withAppDelegate(config, config => {
|
|
134
|
+
let contents = config.modResults.contents;
|
|
135
|
+
|
|
136
|
+
// Check it's Obj-C
|
|
137
|
+
if (!contents.includes("@implementation AppDelegate")) {
|
|
138
|
+
WarningAggregator.addWarningIOS(
|
|
139
|
+
"withObjcNavigationRoot",
|
|
140
|
+
"AppDelegate.m does not appear to be an Objective-C file."
|
|
141
|
+
);
|
|
142
|
+
return config;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Match the method and locate the `return` statement
|
|
146
|
+
const didFinishPattern = /(-\s*\(BOOL\)application:\(UIApplication \*\)application didFinishLaunchingWithOptions:\(NSDictionary \*\)launchOptions\s*\{)([\s\S]*?)(\s+return\s+\[super application:application didFinishLaunchingWithOptions:launchOptions];[\s\S]*?\})/;
|
|
147
|
+
|
|
148
|
+
const match = contents.match(didFinishPattern);
|
|
149
|
+
|
|
150
|
+
if (!match) {
|
|
151
|
+
WarningAggregator.addWarningIOS(
|
|
152
|
+
"withObjcNavigationRoot",
|
|
153
|
+
"`application:didFinishLaunchingWithOptions:` method not found in AppDelegate.m"
|
|
154
|
+
);
|
|
155
|
+
return config;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const [fullMatch, methodStart, methodBody, methodEnd] = match;
|
|
159
|
+
|
|
160
|
+
// Inject just before the return
|
|
161
|
+
const updatedBody = `${methodBody.trimEnd()}\n${NAV_CONTROLLER_SETUP}\n`;
|
|
162
|
+
|
|
163
|
+
const newMethod = `${methodStart}${updatedBody}${methodEnd}`;
|
|
164
|
+
contents = contents.replace(didFinishPattern, newMethod);
|
|
165
|
+
|
|
166
|
+
config.modResults.contents = contents;
|
|
167
|
+
return config;
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
|
|
63
171
|
|
|
64
172
|
module.exports = withDojahKyc;
|
|
@@ -4,9 +4,9 @@ import { DojahKycSdkReactExpoModuleEvents } from './DojahKycSdkReactExpo.types';
|
|
|
4
4
|
|
|
5
5
|
declare class DojahKycSdk extends NativeModule<DojahKycSdkReactExpoModuleEvents> {
|
|
6
6
|
launch(widgetId: string, referenceId?: string | null,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
email?: string | null,
|
|
8
|
+
extraData?: Record<string, any> | null
|
|
9
|
+
): Promise<string>;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
// This call loads the native module object from the JSI.
|