@smile_identity/react-native 10.2.4-beta.1 → 10.2.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/ios/RNDelegates/SmileIDUIViewDelegate.swift +2 -0
- package/ios/RNSmileID.swift +470 -471
- package/ios/Utils/FileUtils.swift +17 -17
- package/ios/Utils/SmileIDDictExt.swift +14 -9
- package/ios/View/BaseSmileIDView.swift +6 -5
- package/ios/View/SmileIDBiometricKYCView.swift +54 -54
- package/ios/View/SmileIDConsentView.swift +2 -1
- package/ios/View/SmileIDDocumentCaptureView.swift +64 -64
- package/ios/View/SmileIDDocumentVerificationView.swift +51 -51
- package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +51 -50
- package/ios/View/SmileIDSmartSelfieAuthEnhancedView.swift +34 -33
- package/ios/View/SmileIDSmartSelfieAuthView.swift +35 -34
- package/ios/View/SmileIDSmartSelfieCaptureView.swift +55 -55
- package/ios/View/SmileIDSmartSelfieEnrollmentEnhancedView.swift +35 -34
- package/ios/View/SmileIDSmartSelfieEnrollmentView.swift +37 -36
- package/ios/ViewManagers/SmileIDBaseViewManager.swift +38 -25
- package/ios/ViewManagers/SmileIDBiometricKYCViewManager.swift +24 -24
- package/ios/ViewManagers/SmileIDConsentViewManager.swift +2 -2
- package/ios/ViewManagers/SmileIDDocumentCaptureViewManager.swift +19 -19
- package/ios/ViewManagers/SmileIDDocumentVerificationViewManager.swift +40 -40
- package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.swift +40 -40
- package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationEnhancedViewManager.swift +16 -16
- package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationViewManager.swift +20 -20
- package/ios/ViewManagers/SmileIDSmartSelfieCaptureViewManager.swift +27 -26
- package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentEnhancedViewManager.swift +16 -16
- package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentViewManager.swift +20 -20
- package/ios/ViewModels/SmileIDProductModel.swift +5 -5
- package/lib/commonjs/useSmileIDView.js +16 -6
- package/lib/commonjs/useSmileIDView.js.map +1 -1
- package/lib/module/useSmileIDView.js +17 -7
- package/lib/module/useSmileIDView.js.map +1 -1
- package/lib/typescript/useSmileIDView.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/useSmileIDView.tsx +17 -9
|
@@ -5,30 +5,30 @@ import SwiftUI
|
|
|
5
5
|
|
|
6
6
|
@objc(SmileIDBiometricKYCViewManager)
|
|
7
7
|
class SmileIDBiometricKYCViewManager: SmileIDBaseViewManager {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
override func getView() -> UIView {
|
|
9
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDBiometricKYCView(product: product, smileIDUIViewDelegate: self)), product: product)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@objc func setParams(_ node: NSNumber, commandId _: NSNumber, params: NSDictionary) {
|
|
13
|
+
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
14
|
+
*/
|
|
15
|
+
DispatchQueue.main.async {
|
|
16
|
+
if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
|
|
17
|
+
let onResult = params["onResult"] as? RCTDirectEventBlock
|
|
18
|
+
guard let idInfo = params["idInfo"] as? NSDictionary else {
|
|
19
|
+
onResult?(["error": SmileIDError.unknown("idInfo is required to run Biometric KYC")])
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
23
|
+
self.product.userId = params["userId"] as? String
|
|
24
|
+
self.product.jobId = params["jobId"] as? String
|
|
25
|
+
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
26
|
+
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
27
|
+
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
28
|
+
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
29
|
+
self.product.idInfo = idInfo.toIdInfo()
|
|
30
|
+
self.product.onResult = onResult
|
|
31
|
+
}
|
|
21
32
|
}
|
|
22
|
-
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
23
|
-
self.product.userId = params["userId"] as? String
|
|
24
|
-
self.product.jobId = params["jobId"] as? String
|
|
25
|
-
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
26
|
-
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
27
|
-
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
28
|
-
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
29
|
-
self.product.idInfo = idInfo.toIdInfo()
|
|
30
|
-
self.product.onResult = onResult
|
|
31
|
-
}
|
|
32
33
|
}
|
|
33
|
-
}
|
|
34
34
|
}
|
|
@@ -6,10 +6,10 @@ import SwiftUI
|
|
|
6
6
|
@objc(SmileIDConsentViewManager)
|
|
7
7
|
class SmileIDConsentViewManager: SmileIDBaseViewManager {
|
|
8
8
|
override func getView() -> UIView {
|
|
9
|
-
|
|
9
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDConsentView(product: product, smileIDUIViewDelegate: self)), product: product)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
@objc func setParams(_ node: NSNumber, commandId _: NSNumber, params: NSDictionary) {
|
|
13
13
|
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
14
14
|
*/
|
|
15
15
|
DispatchQueue.main.async {
|
|
@@ -4,26 +4,26 @@ import SwiftUI
|
|
|
4
4
|
|
|
5
5
|
@objc(SmileIDDocumentCaptureViewManager)
|
|
6
6
|
class SmileIDDocumentCaptureViewManager: SmileIDBaseViewManager {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
override func getView() -> UIView {
|
|
8
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDDocumentCaptureView(product: product, smileIDUIViewDelegate: self)), product: product)
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
@objc func setParams(_ node: NSNumber, commandId _: NSNumber, params: NSDictionary) {
|
|
12
|
+
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
DispatchQueue.main.async {
|
|
15
|
+
if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
|
|
16
|
+
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
17
|
+
self.product.userId = params["userId"] as? String
|
|
18
|
+
self.product.jobId = params["jobId"] as? String
|
|
19
|
+
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
20
|
+
self.product.front = params["isDocumentFrontSide"] as? Bool ?? true
|
|
21
|
+
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
22
|
+
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
23
|
+
self.product.showConfirmation = params["showConfirmation"] as? Bool ?? true
|
|
24
|
+
self.product.allowGalleryUpload = params["allowGalleryUpload"] as? Bool ?? false
|
|
25
|
+
self.product.onResult = params["onResult"] as? RCTBubblingEventBlock
|
|
26
|
+
}
|
|
27
|
+
}
|
|
27
28
|
}
|
|
28
|
-
}
|
|
29
29
|
}
|
|
@@ -5,46 +5,46 @@ import SwiftUI
|
|
|
5
5
|
|
|
6
6
|
@objc(SmileIDDocumentVerificationViewManager)
|
|
7
7
|
class SmileIDDocumentVerificationViewManager: SmileIDBaseViewManager {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
override func getView() -> UIView {
|
|
9
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDDocumentVerificationView(product: product, smileIDUIViewDelegate: self)), product: product)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@objc func setParams(_ node: NSNumber, commandId _: NSNumber, params: NSDictionary) {
|
|
13
|
+
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
14
|
+
*/
|
|
15
|
+
DispatchQueue.main.async {
|
|
16
|
+
if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
|
|
17
|
+
let onResult = params["onResult"] as? RCTDirectEventBlock
|
|
18
|
+
guard let countryCode = params["countryCode"] as? String else {
|
|
19
|
+
onResult?(["error": SmileIDError.unknown("countryCode is required to run Enhanced Document Verification")])
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var bypassSelfieCaptureWithFilePath: URL?
|
|
24
|
+
if let filePath = params["bypassSelfieCaptureWithFile"] as? String {
|
|
25
|
+
if !filePath.isValidUrl() {
|
|
26
|
+
onResult?(["error": SmileIDError.unknown("bypassSelfieCaptureWithFile must be a valid file url")])
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
bypassSelfieCaptureWithFilePath = URL(string: filePath)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
33
|
+
self.product.userId = params["userId"] as? String
|
|
34
|
+
self.product.jobId = params["jobId"] as? String
|
|
35
|
+
self.product.countryCode = countryCode
|
|
36
|
+
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
37
|
+
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
38
|
+
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
39
|
+
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
40
|
+
self.product.documentType = params["documentType"] as? String
|
|
41
|
+
self.product.idAspectRatio = params["idAspectRatio"] as? Double
|
|
42
|
+
self.product.bypassSelfieCaptureWithFilePath = bypassSelfieCaptureWithFilePath
|
|
43
|
+
self.product.captureBothSides = params["captureBothSides"] as? Bool ?? true
|
|
44
|
+
self.product.allowGalleryUpload = params["allowGalleryUpload"] as? Bool ?? false
|
|
45
|
+
self.product.skipApiSubmission = params["skipApiSubmission"] as? Bool ?? false
|
|
46
|
+
self.product.onResult = params["onResult"] as? RCTDirectEventBlock
|
|
47
|
+
}
|
|
30
48
|
}
|
|
31
|
-
|
|
32
|
-
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
33
|
-
self.product.userId = params["userId"] as? String
|
|
34
|
-
self.product.jobId = params["jobId"] as? String
|
|
35
|
-
self.product.countryCode = countryCode
|
|
36
|
-
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
37
|
-
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
38
|
-
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
39
|
-
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
40
|
-
self.product.documentType = params["documentType"] as? String
|
|
41
|
-
self.product.idAspectRatio = params["idAspectRatio"] as? Double
|
|
42
|
-
self.product.bypassSelfieCaptureWithFilePath = bypassSelfieCaptureWithFilePath
|
|
43
|
-
self.product.captureBothSides = params["captureBothSides"] as? Bool ?? true
|
|
44
|
-
self.product.allowGalleryUpload = params["allowGalleryUpload"] as? Bool ?? false
|
|
45
|
-
self.product.skipApiSubmission = params["skipApiSubmission"] as? Bool ?? false
|
|
46
|
-
self.product.onResult = params["onResult"] as? RCTDirectEventBlock
|
|
47
|
-
}
|
|
48
49
|
}
|
|
49
|
-
}
|
|
50
50
|
}
|
|
@@ -5,46 +5,46 @@ import SwiftUI
|
|
|
5
5
|
|
|
6
6
|
@objc(SmileIDEnhancedDocumentVerificationViewManager)
|
|
7
7
|
class SmileIDEnhancedDocumentVerificationViewManager: SmileIDBaseViewManager {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
override func getView() -> UIView {
|
|
9
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDEnhancedDocumentVerificationView(product: product, smileIDUIViewDelegate: self)), product: product)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@objc func setParams(_ node: NSNumber, commandId _: NSNumber, params: NSDictionary) {
|
|
13
|
+
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
14
|
+
*/
|
|
15
|
+
DispatchQueue.main.async {
|
|
16
|
+
if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
|
|
17
|
+
let onResult = params["onResult"] as? RCTDirectEventBlock
|
|
18
|
+
guard let countryCode = params["countryCode"] as? String else {
|
|
19
|
+
onResult?(["error": SmileIDError.unknown("countryCode is required to run Enhanced Document Verification")])
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var bypassSelfieCaptureWithFilePath: URL?
|
|
24
|
+
if let filePath = params["bypassSelfieCaptureWithFile"] as? String {
|
|
25
|
+
if !filePath.isValidUrl() {
|
|
26
|
+
onResult?(["error": SmileIDError.unknown("bypassSelfieCaptureWithFile must be a valid file url")])
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
bypassSelfieCaptureWithFilePath = URL(string: filePath)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
33
|
+
self.product.userId = params["userId"] as? String
|
|
34
|
+
self.product.jobId = params["jobId"] as? String
|
|
35
|
+
self.product.countryCode = countryCode
|
|
36
|
+
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
37
|
+
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
38
|
+
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
39
|
+
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
40
|
+
self.product.documentType = params["documentType"] as? String
|
|
41
|
+
self.product.idAspectRatio = params["idAspectRatio"] as? Double
|
|
42
|
+
self.product.bypassSelfieCaptureWithFilePath = bypassSelfieCaptureWithFilePath
|
|
43
|
+
self.product.captureBothSides = params["captureBothSides"] as? Bool ?? true
|
|
44
|
+
self.product.allowGalleryUpload = params["allowGalleryUpload"] as? Bool ?? false
|
|
45
|
+
self.product.skipApiSubmission = params["skipApiSubmission"] as? Bool ?? false
|
|
46
|
+
self.product.onResult = params["onResult"] as? RCTDirectEventBlock
|
|
47
|
+
}
|
|
30
48
|
}
|
|
31
|
-
|
|
32
|
-
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
33
|
-
self.product.userId = params["userId"] as? String
|
|
34
|
-
self.product.jobId = params["jobId"] as? String
|
|
35
|
-
self.product.countryCode = countryCode
|
|
36
|
-
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
37
|
-
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
38
|
-
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
39
|
-
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
40
|
-
self.product.documentType = params["documentType"] as? String
|
|
41
|
-
self.product.idAspectRatio = params["idAspectRatio"] as? Double
|
|
42
|
-
self.product.bypassSelfieCaptureWithFilePath = bypassSelfieCaptureWithFilePath
|
|
43
|
-
self.product.captureBothSides = params["captureBothSides"] as? Bool ?? true
|
|
44
|
-
self.product.allowGalleryUpload = params["allowGalleryUpload"] as? Bool ?? false
|
|
45
|
-
self.product.skipApiSubmission = params["skipApiSubmission"] as? Bool ?? false
|
|
46
|
-
self.product.onResult = params["onResult"] as? RCTDirectEventBlock
|
|
47
|
-
}
|
|
48
49
|
}
|
|
49
|
-
}
|
|
50
50
|
}
|
|
@@ -4,22 +4,22 @@ import SwiftUI
|
|
|
4
4
|
|
|
5
5
|
@objc(SmileIDSmartSelfieAuthenticationEnhancedViewManager)
|
|
6
6
|
class SmileIDSmartSelfieAuthenticationEnhancedViewManager: SmileIDBaseViewManager {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
override func getView() -> UIView {
|
|
8
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDSmartSelfieAuthEnhancedView(product: product, smileIDUIViewDelegate: self)), product: product)
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
@objc func setParams(_ node: NSNumber, commandId _: NSNumber, params: NSDictionary) {
|
|
12
|
+
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
13
|
+
*/
|
|
14
|
+
DispatchQueue.main.async {
|
|
15
|
+
if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
|
|
16
|
+
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
17
|
+
self.product.userId = params["userId"] as? String
|
|
18
|
+
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
19
|
+
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
20
|
+
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
21
|
+
self.product.onResult = params["onResult"] as? RCTDirectEventBlock
|
|
22
|
+
}
|
|
23
|
+
}
|
|
23
24
|
}
|
|
24
|
-
}
|
|
25
25
|
}
|
|
@@ -4,25 +4,25 @@ import SwiftUI
|
|
|
4
4
|
|
|
5
5
|
@objc(SmileIDSmartSelfieAuthenticationViewManager)
|
|
6
6
|
class SmileIDSmartSelfieAuthenticationViewManager: SmileIDBaseViewManager {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
override func getView() -> UIView {
|
|
8
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDSmartSelfieAuthView(product: product, smileIDUIViewDelegate: self)), product: product)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc func setParams(_ node: NSNumber, commandId _: NSNumber, params: NSDictionary) {
|
|
12
|
+
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
13
|
+
*/
|
|
14
|
+
DispatchQueue.main.async {
|
|
15
|
+
if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
|
|
16
|
+
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
17
|
+
self.product.userId = params["userId"] as? String
|
|
18
|
+
self.product.jobId = params["jobId"] as? String
|
|
19
|
+
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
20
|
+
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
21
|
+
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
22
|
+
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
23
|
+
self.product.skipApiSubmission = params["skipApiSubmission"] as? Bool ?? false
|
|
24
|
+
self.product.onResult = params["onResult"] as? RCTDirectEventBlock
|
|
25
|
+
}
|
|
26
|
+
}
|
|
26
27
|
}
|
|
27
|
-
}
|
|
28
28
|
}
|
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import React
|
|
3
|
-
import SwiftUI
|
|
4
3
|
import SmileID
|
|
4
|
+
import SwiftUI
|
|
5
5
|
|
|
6
6
|
@objc(SmileIDSmartSelfieCaptureViewManager)
|
|
7
7
|
class SmileIDSmartSelfieCaptureViewManager: SmileIDBaseViewManager {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
override func getView() -> UIView {
|
|
9
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(
|
|
10
|
+
SmileIDSmartSelfieCaptureView(
|
|
11
|
+
viewModel: SelfieViewModel(isEnroll: false,
|
|
12
|
+
userId: product.userId ?? generateUserId(),
|
|
13
|
+
jobId: product.jobId ?? generateJobId(),
|
|
14
|
+
allowNewEnroll: false,
|
|
15
|
+
skipApiSubmission: true,
|
|
16
|
+
extraPartnerParams: [:],
|
|
17
|
+
localMetadata: LocalMetadata()), product: product, smileIDUIViewDelegate: self
|
|
18
|
+
)),
|
|
19
|
+
product: product)
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
@objc func setParams(_ node: NSNumber, commandId _: NSNumber, params: NSDictionary) {
|
|
23
|
+
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
DispatchQueue.main.async {
|
|
26
|
+
if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
|
|
27
|
+
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
28
|
+
self.product.userId = params["userId"] as? String
|
|
29
|
+
self.product.jobId = params["jobId"] as? String
|
|
30
|
+
self.product.showConfirmation = params["showConfirmation"] as? Bool ?? true
|
|
31
|
+
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
32
|
+
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
33
|
+
self.product.onResult = params["onResult"] as? RCTBubblingEventBlock
|
|
34
|
+
}
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
|
-
}
|
|
36
37
|
}
|
|
@@ -4,22 +4,22 @@ import SwiftUI
|
|
|
4
4
|
|
|
5
5
|
@objc(SmileIDSmartSelfieEnrollmentEnhancedViewManager)
|
|
6
6
|
class SmileIDSmartSelfieEnrollmentEnhancedViewManager: SmileIDBaseViewManager {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
override func getView() -> UIView {
|
|
8
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDSmartSelfieEnrollmentEnhancedView(product: product, smileIDUIViewDelegate: self)), product: product)
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
@objc func setParams(_ node: NSNumber, commandId _: NSNumber, params: NSDictionary) {
|
|
12
|
+
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
13
|
+
*/
|
|
14
|
+
DispatchQueue.main.async {
|
|
15
|
+
if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
|
|
16
|
+
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
17
|
+
self.product.userId = params["userId"] as? String
|
|
18
|
+
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
19
|
+
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
20
|
+
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
21
|
+
self.product.onResult = params["onResult"] as? RCTBubblingEventBlock
|
|
22
|
+
}
|
|
23
|
+
}
|
|
23
24
|
}
|
|
24
|
-
}
|
|
25
25
|
}
|
|
@@ -4,25 +4,25 @@ import SwiftUI
|
|
|
4
4
|
|
|
5
5
|
@objc(SmileIDSmartSelfieEnrollmentViewManager)
|
|
6
6
|
class SmileIDSmartSelfieEnrollmentViewManager: SmileIDBaseViewManager {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
override func getView() -> UIView {
|
|
8
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDSmartSelfieEnrollmentView(product: product, smileIDUIViewDelegate: self)), product: product)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc func setParams(_ node: NSNumber, commandId _: NSNumber, params: NSDictionary) {
|
|
12
|
+
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
13
|
+
*/
|
|
14
|
+
DispatchQueue.main.async {
|
|
15
|
+
if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
|
|
16
|
+
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
17
|
+
self.product.userId = params["userId"] as? String
|
|
18
|
+
self.product.jobId = params["jobId"] as? String
|
|
19
|
+
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
20
|
+
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
21
|
+
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
22
|
+
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
23
|
+
self.product.skipApiSubmission = params["skipApiSubmission"] as? Bool ?? false
|
|
24
|
+
self.product.onResult = params["onResult"] as? RCTBubblingEventBlock
|
|
25
|
+
}
|
|
26
|
+
}
|
|
26
27
|
}
|
|
27
|
-
}
|
|
28
28
|
}
|
|
@@ -2,11 +2,11 @@ import Combine
|
|
|
2
2
|
import Foundation
|
|
3
3
|
import SmileID
|
|
4
4
|
|
|
5
|
-
//We're making this a central place to observe
|
|
6
|
-
//changes published after props have been updated
|
|
7
|
-
//from react native side the main thing being that
|
|
8
|
-
//when views are instantiated we don't have all the props
|
|
9
|
-
//also state could change
|
|
5
|
+
// We're making this a central place to observe
|
|
6
|
+
// changes published after props have been updated
|
|
7
|
+
// from react native side the main thing being that
|
|
8
|
+
// when views are instantiated we don't have all the props
|
|
9
|
+
// also state could change
|
|
10
10
|
class SmileIDProductModel: ObservableObject {
|
|
11
11
|
@Published var userId: String?
|
|
12
12
|
@Published var jobId: String?
|
|
@@ -8,22 +8,32 @@ var _react = require("react");
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
const useSmileIDView = (viewName, props) => {
|
|
10
10
|
const viewRef = (0, _react.useRef)(null);
|
|
11
|
+
const [viewProps, setViewProps] = (0, _react.useState)(props);
|
|
12
|
+
const onResultRef = (0, _react.useRef)(viewProps.onResult);
|
|
13
|
+
(0, _react.useEffect)(() => {
|
|
14
|
+
onResultRef.current = viewProps.onResult;
|
|
15
|
+
}, [viewProps.onResult]);
|
|
11
16
|
(0, _react.useEffect)(() => {
|
|
12
17
|
const eventListener = _reactNative.DeviceEventEmitter.addListener('onSmileResult', event => {
|
|
13
|
-
|
|
18
|
+
// Use the ref to access the latest callback
|
|
19
|
+
setViewProps(prev => ({
|
|
20
|
+
...prev,
|
|
21
|
+
userId: 'invalidator'
|
|
22
|
+
}));
|
|
23
|
+
if (onResultRef.current) {
|
|
14
24
|
const nativeEvent = {
|
|
15
25
|
nativeEvent: {
|
|
16
26
|
error: event.error,
|
|
17
27
|
result: event.result
|
|
18
28
|
}
|
|
19
29
|
};
|
|
20
|
-
|
|
30
|
+
onResultRef.current(nativeEvent);
|
|
21
31
|
}
|
|
22
32
|
});
|
|
23
33
|
return () => {
|
|
24
34
|
eventListener.remove();
|
|
25
35
|
};
|
|
26
|
-
}, [
|
|
36
|
+
}, []);
|
|
27
37
|
(0, _react.useEffect)(() => {
|
|
28
38
|
const viewId = (0, _reactNative.findNodeHandle)(viewRef.current);
|
|
29
39
|
const commandId = _reactNative.UIManager.getViewManagerConfig(viewName).Commands.create;
|
|
@@ -32,12 +42,12 @@ const useSmileIDView = (viewName, props) => {
|
|
|
32
42
|
if (typeof commandId !== 'undefined') {
|
|
33
43
|
_reactNative.UIManager.dispatchViewManagerCommand((0, _reactNative.findNodeHandle)(viewRef.current), _reactNative.Platform.OS === 'android' ? commandId.toString() : commandId, [viewId]);
|
|
34
44
|
} else {
|
|
35
|
-
throw new Error('Command "
|
|
45
|
+
throw new Error('Command "create" is not defined for MyNativeComponent');
|
|
36
46
|
}
|
|
37
47
|
}, [viewName]);
|
|
38
48
|
(0, _react.useEffect)(() => {
|
|
39
49
|
const parameters = {
|
|
40
|
-
...
|
|
50
|
+
...viewProps
|
|
41
51
|
};
|
|
42
52
|
const viewId = (0, _reactNative.findNodeHandle)(viewRef.current);
|
|
43
53
|
const commandId = _reactNative.UIManager.getViewManagerConfig(viewName).Commands.setParams;
|
|
@@ -48,7 +58,7 @@ const useSmileIDView = (viewName, props) => {
|
|
|
48
58
|
} else {
|
|
49
59
|
throw new Error('Command "setParams" is not defined for MyNativeComponent');
|
|
50
60
|
}
|
|
51
|
-
}, [
|
|
61
|
+
}, [viewProps, viewName]);
|
|
52
62
|
return viewRef;
|
|
53
63
|
};
|
|
54
64
|
exports.useSmileIDView = useSmileIDView;
|