@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
|
@@ -2,59 +2,60 @@ import Foundation
|
|
|
2
2
|
import SmileID
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
|
-
struct SmileIDEnhancedDocumentVerificationView: View,SmileIDFileUtilsProtocol {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
5
|
+
struct SmileIDEnhancedDocumentVerificationView: View, SmileIDFileUtilsProtocol {
|
|
6
|
+
var fileManager: FileManager = Foundation.FileManager.default
|
|
7
|
+
@ObservedObject var product: SmileIDProductModel
|
|
8
|
+
var smileIDUIViewDelegate: SmileIDUIViewDelegate
|
|
9
|
+
var body: some View {
|
|
10
|
+
NavigationView {
|
|
11
|
+
if let countryCode = product.countryCode {
|
|
12
|
+
SmileID.enhancedDocumentVerificationScreen(
|
|
13
|
+
userId: product.userId ?? generateUserId(),
|
|
14
|
+
jobId: product.jobId ?? generateJobId(),
|
|
15
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
16
|
+
countryCode: countryCode, // already validated in the view manager
|
|
17
|
+
documentType: product.documentType,
|
|
18
|
+
idAspectRatio: product.idAspectRatio,
|
|
19
|
+
bypassSelfieCaptureWithFile: product.bypassSelfieCaptureWithFilePath,
|
|
20
|
+
captureBothSides: product.captureBothSides,
|
|
21
|
+
allowAgentMode: product.allowAgentMode,
|
|
22
|
+
allowGalleryUpload: product.allowGalleryUpload,
|
|
23
|
+
showInstructions: product.showInstructions,
|
|
24
|
+
skipApiSubmission: product.skipApiSubmission,
|
|
25
|
+
showAttribution: product.showAttribution,
|
|
26
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
27
|
+
delegate: self
|
|
28
|
+
)
|
|
29
|
+
} else {
|
|
30
|
+
// This exists for debugging purposes and will show in extreme cases
|
|
31
|
+
// when the params were not set NB: setParams in the viewmanager will always
|
|
32
|
+
// return an error if the required data is missing
|
|
33
|
+
Text("An error has occured")
|
|
34
|
+
}
|
|
35
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
36
|
+
}
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
extension SmileIDEnhancedDocumentVerificationView: EnhancedDocumentVerificationResultDelegate {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitEnhancedDocVJob: Bool) {
|
|
41
|
+
var params: [String: Any] = [
|
|
42
|
+
"selfieFile": getFilePath(fileName: selfie.absoluteString),
|
|
43
|
+
"documentFrontFile": getFilePath(fileName: documentFrontImage.absoluteString),
|
|
44
|
+
"didSubmitEnhancedDocVJob": didSubmitEnhancedDocVJob,
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
if let documentBackImage = documentBackImage {
|
|
48
|
+
params["documentBackFile"] = getFilePath(fileName: documentBackImage.absoluteString)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
52
|
+
smileIDUIViewDelegate.onError(error: SmileIDError.unknown("SmileIDEnhancedDocumentVerificationView encoding error"))
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
smileIDUIViewDelegate.onResult(smileResult: String(data: jsonData, encoding: .utf8)!)
|
|
48
56
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return
|
|
57
|
+
|
|
58
|
+
func didError(error: Error) {
|
|
59
|
+
smileIDUIViewDelegate.onError(error: error.localizedDescription)
|
|
53
60
|
}
|
|
54
|
-
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
func didError(error: Error) {
|
|
58
|
-
product.onResult?(["error": error.localizedDescription])
|
|
59
|
-
}
|
|
60
61
|
}
|
|
@@ -2,43 +2,44 @@ import Foundation
|
|
|
2
2
|
import SmileID
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
|
-
struct SmileIDSmartSelfieAuthEnhancedView: View,SmileIDFileUtilsProtocol {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
struct SmileIDSmartSelfieAuthEnhancedView: View, SmileIDFileUtilsProtocol {
|
|
6
|
+
var fileManager: FileManager = Foundation.FileManager.default
|
|
7
|
+
@ObservedObject var product: SmileIDProductModel
|
|
8
|
+
var smileIDUIViewDelegate: SmileIDUIViewDelegate
|
|
9
|
+
var body: some View {
|
|
10
|
+
NavigationView {
|
|
11
|
+
SmileID.smartSelfieAuthenticationScreenEnhanced(
|
|
12
|
+
userId: product.userId ?? generateUserId(),
|
|
13
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
14
|
+
showAttribution: product.showAttribution,
|
|
15
|
+
showInstructions: product.showInstructions,
|
|
16
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
17
|
+
delegate: self
|
|
18
|
+
)
|
|
19
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
20
|
+
}
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
extension SmileIDSmartSelfieAuthEnhancedView: SmartSelfieResultDelegate {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
|
|
25
|
+
var params: [String: Any] = [
|
|
26
|
+
"selfieFile": getFilePath(fileName: selfieImage.absoluteString),
|
|
27
|
+
"livenessFiles": livenessImages.map {
|
|
28
|
+
getFilePath(fileName: $0.absoluteString)
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
if let apiResponse = apiResponse {
|
|
32
|
+
params["apiResponse"] = apiResponse
|
|
33
|
+
}
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
36
|
+
smileIDUIViewDelegate.onError(error: SmileIDError.unknown("SmileIDSmartSelfieAuthView encoding error"))
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
smileIDUIViewDelegate.onResult(smileResult: String(data: jsonData, encoding: .utf8)!)
|
|
37
40
|
}
|
|
38
|
-
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
39
|
-
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
func didError(error: Error) {
|
|
43
|
+
smileIDUIViewDelegate.onError(error: error.localizedDescription)
|
|
44
|
+
}
|
|
44
45
|
}
|
|
@@ -2,44 +2,45 @@ import Foundation
|
|
|
2
2
|
import SmileID
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
|
-
struct SmileIDSmartSelfieAuthView: View,SmileIDFileUtilsProtocol {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
struct SmileIDSmartSelfieAuthView: View, SmileIDFileUtilsProtocol {
|
|
6
|
+
var fileManager: FileManager = Foundation.FileManager.default
|
|
7
|
+
@ObservedObject var product: SmileIDProductModel
|
|
8
|
+
var smileIDUIViewDelegate: SmileIDUIViewDelegate
|
|
9
|
+
var body: some View {
|
|
10
|
+
NavigationView {
|
|
11
|
+
SmileID.smartSelfieAuthenticationScreen(
|
|
12
|
+
userId: product.userId ?? generateUserId(),
|
|
13
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
14
|
+
allowAgentMode: product.allowAgentMode,
|
|
15
|
+
showAttribution: product.showAttribution,
|
|
16
|
+
showInstructions: product.showInstructions,
|
|
17
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
18
|
+
delegate: self
|
|
19
|
+
)
|
|
20
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
21
|
+
}
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
extension SmileIDSmartSelfieAuthView: SmartSelfieResultDelegate {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
|
|
26
|
+
var params: [String: Any] = [
|
|
27
|
+
"selfieFile": getFilePath(fileName: selfieImage.absoluteString),
|
|
28
|
+
"livenessFiles": livenessImages.map {
|
|
29
|
+
getFilePath(fileName: $0.absoluteString)
|
|
30
|
+
},
|
|
31
|
+
]
|
|
32
|
+
if let apiResponse = apiResponse {
|
|
33
|
+
params["apiResponse"] = apiResponse
|
|
34
|
+
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
37
|
+
smileIDUIViewDelegate.onError(error: SmileIDError.unknown("SmileIDSmartSelfieAuthView encoding error"))
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
smileIDUIViewDelegate.onResult(smileResult: String(data: jsonData, encoding: .utf8)!)
|
|
38
41
|
}
|
|
39
|
-
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
40
|
-
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
func didError(error: Error) {
|
|
44
|
+
smileIDUIViewDelegate.onError(error: error.localizedDescription)
|
|
45
|
+
}
|
|
45
46
|
}
|
|
@@ -2,70 +2,70 @@ import Foundation
|
|
|
2
2
|
import SmileID
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
struct SmileIDSmartSelfieCaptureView: View, SmileIDFileUtilsProtocol {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
var fileManager: FileManager = Foundation.FileManager.default
|
|
7
|
+
@ObservedObject var viewModel: SelfieViewModel
|
|
8
|
+
@ObservedObject var product: SmileIDProductModel
|
|
9
|
+
@State private var acknowledgedInstructions = false
|
|
10
|
+
var smileIDUIViewDelegate: SmileIDUIViewDelegate
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
12
|
+
var body: some View {
|
|
13
|
+
NavigationView {
|
|
14
|
+
Group {
|
|
15
|
+
if product.showInstructions, !acknowledgedInstructions {
|
|
16
|
+
SmartSelfieInstructionsScreen(showAttribution: product.showAttribution) {
|
|
17
|
+
acknowledgedInstructions = true
|
|
18
|
+
}
|
|
19
|
+
} else if viewModel.processingState != nil {
|
|
20
|
+
Color.clear.onAppear {
|
|
21
|
+
self.viewModel.onFinished(callback: self)
|
|
22
|
+
}
|
|
23
|
+
} else if let selfieToConfirm = viewModel.selfieToConfirm {
|
|
24
|
+
if self.product.showConfirmation {
|
|
25
|
+
ImageCaptureConfirmationDialog(
|
|
26
|
+
title: SmileIDResourcesHelper.localizedString(for: "Confirmation.GoodSelfie"),
|
|
27
|
+
subtitle: SmileIDResourcesHelper.localizedString(for: "Confirmation.FaceClear"),
|
|
28
|
+
image: UIImage(data: selfieToConfirm)!,
|
|
29
|
+
confirmationButtonText: SmileIDResourcesHelper.localizedString(for: "Confirmation.YesUse"),
|
|
30
|
+
onConfirm: viewModel.submitJob,
|
|
31
|
+
retakeButtonText: SmileIDResourcesHelper.localizedString(for: "Confirmation.Retake"),
|
|
32
|
+
onRetake: viewModel.onSelfieRejected,
|
|
33
|
+
scaleFactor: 1.25
|
|
34
|
+
).preferredColorScheme(.light)
|
|
35
|
+
} else {
|
|
36
|
+
Color.clear.onAppear {
|
|
37
|
+
self.viewModel.submitJob()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
SelfieCaptureScreen(
|
|
42
|
+
viewModel: viewModel,
|
|
43
|
+
allowAgentMode: self.product.allowAgentMode
|
|
44
|
+
).preferredColorScheme(.light)
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
SelfieCaptureScreen(
|
|
42
|
-
viewModel: viewModel,
|
|
43
|
-
allowAgentMode: self.product.allowAgentMode
|
|
44
|
-
).preferredColorScheme(.light)
|
|
45
47
|
}
|
|
46
|
-
|
|
48
|
+
.navigationViewStyle(StackNavigationViewStyle()).padding()
|
|
47
49
|
}
|
|
48
|
-
.navigationViewStyle(StackNavigationViewStyle()).padding()
|
|
49
|
-
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
extension SmileIDSmartSelfieCaptureView: SmartSelfieResultDelegate {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse _: SmartSelfieResponse?) {
|
|
54
|
+
let params: [String: Any] = [
|
|
55
|
+
"selfieFile": getFilePath(fileName: selfieImage.absoluteString),
|
|
56
|
+
"livenessFiles": livenessImages.map {
|
|
57
|
+
getFilePath(fileName: $0.absoluteString)
|
|
58
|
+
},
|
|
59
|
+
]
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
62
|
+
smileIDUIViewDelegate.onError(error: SmileIDError.unknown("SmileIDSmartSelfieCaptureView encoding error"))
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
smileIDUIViewDelegate.onResult(smileResult: String(data: jsonData, encoding: .utf8)!)
|
|
64
66
|
}
|
|
65
|
-
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
66
|
-
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
func didError(error: Error) {
|
|
69
|
+
smileIDUIViewDelegate.onError(error: error.localizedDescription)
|
|
70
|
+
}
|
|
71
71
|
}
|
|
@@ -2,43 +2,44 @@ import Foundation
|
|
|
2
2
|
import SmileID
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
|
-
struct SmileIDSmartSelfieEnrollmentEnhancedView: View,SmileIDFileUtilsProtocol {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
struct SmileIDSmartSelfieEnrollmentEnhancedView: View, SmileIDFileUtilsProtocol {
|
|
6
|
+
var fileManager: FileManager = Foundation.FileManager.default
|
|
7
|
+
@ObservedObject var product: SmileIDProductModel
|
|
8
|
+
var smileIDUIViewDelegate: SmileIDUIViewDelegate
|
|
9
|
+
var body: some View {
|
|
10
|
+
NavigationView {
|
|
11
|
+
SmileID.smartSelfieEnrollmentScreenEnhanced(
|
|
12
|
+
userId: product.userId ?? generateUserId(),
|
|
13
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
14
|
+
showAttribution: product.showAttribution,
|
|
15
|
+
showInstructions: product.showInstructions,
|
|
16
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
17
|
+
delegate: self
|
|
18
|
+
)
|
|
19
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
20
|
+
}
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
extension SmileIDSmartSelfieEnrollmentEnhancedView: SmartSelfieResultDelegate {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
|
|
25
|
+
var params: [String: Any] = [
|
|
26
|
+
"selfieFile": getFilePath(fileName: selfieImage.absoluteString),
|
|
27
|
+
"livenessFiles": livenessImages.map {
|
|
28
|
+
getFilePath(fileName: $0.absoluteString)
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
if let apiResponse = apiResponse {
|
|
32
|
+
params["apiResponse"] = apiResponse
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
36
|
+
smileIDUIViewDelegate.onError(error: SmileIDError.unknown("SmileIDSmartSelfieEnrollmentView encoding error"))
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
smileIDUIViewDelegate.onResult(smileResult: String(data: jsonData, encoding: .utf8)!)
|
|
32
40
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return
|
|
41
|
+
|
|
42
|
+
func didError(error: Error) {
|
|
43
|
+
smileIDUIViewDelegate.onError(error: error.localizedDescription)
|
|
37
44
|
}
|
|
38
|
-
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
func didError(error: Error) {
|
|
42
|
-
product.onResult?(["error": error.localizedDescription])
|
|
43
|
-
}
|
|
44
45
|
}
|
|
@@ -2,45 +2,46 @@ import Foundation
|
|
|
2
2
|
import SmileID
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
|
-
struct SmileIDSmartSelfieEnrollmentView: View,SmileIDFileUtilsProtocol {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
struct SmileIDSmartSelfieEnrollmentView: View, SmileIDFileUtilsProtocol {
|
|
6
|
+
var fileManager: FileManager = Foundation.FileManager.default
|
|
7
|
+
@ObservedObject var product: SmileIDProductModel
|
|
8
|
+
var smileIDUIViewDelegate: SmileIDUIViewDelegate
|
|
9
|
+
var body: some View {
|
|
10
|
+
NavigationView {
|
|
11
|
+
SmileID.smartSelfieEnrollmentScreen(
|
|
12
|
+
userId: product.userId ?? generateUserId(),
|
|
13
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
14
|
+
allowAgentMode: product.allowAgentMode,
|
|
15
|
+
showAttribution: product.showAttribution,
|
|
16
|
+
showInstructions: product.showInstructions,
|
|
17
|
+
skipApiSubmission: product.skipApiSubmission,
|
|
18
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
19
|
+
delegate: self
|
|
20
|
+
)
|
|
21
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
22
|
+
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
extension SmileIDSmartSelfieEnrollmentView: SmartSelfieResultDelegate {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
|
|
27
|
+
var params: [String: Any] = [
|
|
28
|
+
"selfieFile": getFilePath(fileName: selfieImage.absoluteString),
|
|
29
|
+
"livenessFiles": livenessImages.map {
|
|
30
|
+
getFilePath(fileName: $0.absoluteString)
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
if let apiResponse = apiResponse {
|
|
34
|
+
params["apiResponse"] = apiResponse
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
38
|
+
smileIDUIViewDelegate.onError(error: SmileIDError.unknown("SmileIDSmartSelfieEnrollmentView encoding error"))
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
smileIDUIViewDelegate.onResult(smileResult: String(data: jsonData, encoding: .utf8)!)
|
|
34
42
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
43
|
+
|
|
44
|
+
func didError(error: Error) {
|
|
45
|
+
smileIDUIViewDelegate.onError(error: error.localizedDescription)
|
|
39
46
|
}
|
|
40
|
-
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
func didError(error: Error) {
|
|
44
|
-
product.onResult?(["error": error.localizedDescription])
|
|
45
|
-
}
|
|
46
47
|
}
|
|
@@ -3,29 +3,42 @@ import React
|
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
5
|
class SmileIDBaseViewManager: RCTViewManager, SmileIDUIViewDelegate {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
6
|
+
var product = SmileIDProductModel()
|
|
7
|
+
@objc var onResult: RCTDirectEventBlock?
|
|
8
|
+
@objc var currentNode: NSNumber?
|
|
9
|
+
func getView() -> UIView {
|
|
10
|
+
fatalError("Must be implemented by subclass")
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@objc open func create(_: NSNumber, params _: NSDictionary) {}
|
|
14
|
+
|
|
15
|
+
func onResult(smileResult: String) {
|
|
16
|
+
bridge.eventDispatcher().sendDeviceEvent(
|
|
17
|
+
withName: "onSmileResult",
|
|
18
|
+
body: ["result": smileResult]
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
func onError(error: any Error) {
|
|
23
|
+
bridge.eventDispatcher().sendDeviceEvent(
|
|
24
|
+
withName: "onSmileResult",
|
|
25
|
+
body: ["error": error]
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override func view() -> UIView! {
|
|
30
|
+
getView()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override func customBubblingEventTypes() -> [String]! {
|
|
34
|
+
return ["onResult"]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@objc override func constantsToExport() -> [AnyHashable: Any]! {
|
|
38
|
+
return ["onResult": "onResult"]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
42
|
+
return true
|
|
43
|
+
}
|
|
31
44
|
}
|