Skip to content

Commit 7ae74b3

Browse files
✨ Improve IdcheckioViewController configuration.
1 parent a33996c commit 7ae74b3

File tree

7 files changed

+92
-46
lines changed

7 files changed

+92
-46
lines changed

idcheckio-sdk-sample-ios/idcheckio-sdk-sample-ios.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
7C23A43726AAFEAB00FFA724 /* ExternalAccessory.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7C23A43626AAFEAB00FFA724 /* ExternalAccessory.framework */; };
1011
7CB20C1A269835D400AD4B7A /* SDKConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CB20C19269835D400AD4B7A /* SDKConfig.swift */; };
1112
B603EDD825F76CE200E2CE7A /* OnlineFlowCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B603EDD725F76CE200E2CE7A /* OnlineFlowCoordinator.swift */; };
1213
B603EDDB25F775DB00E2CE7A /* OnlineFlowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B603EDDA25F775DB00E2CE7A /* OnlineFlowViewController.swift */; };
@@ -36,6 +37,8 @@
3637
/* Begin PBXFileReference section */
3738
418B464675DEF51D9644AC88 /* Pods-idcheckio-sdk-sample-ios.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-idcheckio-sdk-sample-ios.release.xcconfig"; path = "Target Support Files/Pods-idcheckio-sdk-sample-ios/Pods-idcheckio-sdk-sample-ios.release.xcconfig"; sourceTree = "<group>"; };
3839
6EBC2A146FC0F209DAAC3168 /* Pods_idcheckio_sdk_sample_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_idcheckio_sdk_sample_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
40+
7C23A43526AAFEAB00FFA724 /* idcheckio-sdk-sample-ios.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "idcheckio-sdk-sample-ios.entitlements"; sourceTree = "<group>"; };
41+
7C23A43626AAFEAB00FFA724 /* ExternalAccessory.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ExternalAccessory.framework; path = System/Library/Frameworks/ExternalAccessory.framework; sourceTree = SDKROOT; };
3942
7CB20C19269835D400AD4B7A /* SDKConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDKConfig.swift; sourceTree = "<group>"; };
4043
B603EDD725F76CE200E2CE7A /* OnlineFlowCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnlineFlowCoordinator.swift; sourceTree = "<group>"; };
4144
B603EDDA25F775DB00E2CE7A /* OnlineFlowViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnlineFlowViewController.swift; sourceTree = "<group>"; };
@@ -69,6 +72,7 @@
6972
isa = PBXFrameworksBuildPhase;
7073
buildActionMask = 2147483647;
7174
files = (
75+
7C23A43726AAFEAB00FFA724 /* ExternalAccessory.framework in Frameworks */,
7276
E48FF7404235C09CE9C307A6 /* Pods_idcheckio_sdk_sample_ios.framework in Frameworks */,
7377
);
7478
runOnlyForDeploymentPostprocessing = 0;
@@ -79,6 +83,7 @@
7983
A26B62201C82186D89EAF6A8 /* Frameworks */ = {
8084
isa = PBXGroup;
8185
children = (
86+
7C23A43626AAFEAB00FFA724 /* ExternalAccessory.framework */,
8287
6EBC2A146FC0F209DAAC3168 /* Pods_idcheckio_sdk_sample_ios.framework */,
8388
);
8489
name = Frameworks;
@@ -155,6 +160,7 @@
155160
B6D8222625BB1B7500FFF853 /* idcheckio-sdk-sample-ios */ = {
156161
isa = PBXGroup;
157162
children = (
163+
7C23A43526AAFEAB00FFA724 /* idcheckio-sdk-sample-ios.entitlements */,
158164
B6750FBE25F135AF0011A536 /* Analyze */,
159165
B674366625ECF50500F817CF /* Utils */,
160166
B60857BC25C07E1600AABCBB /* Coordinator */,
@@ -471,6 +477,7 @@
471477
buildSettings = {
472478
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
473479
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
480+
CODE_SIGN_ENTITLEMENTS = "idcheckio-sdk-sample-ios/idcheckio-sdk-sample-ios.entitlements";
474481
CODE_SIGN_STYLE = Automatic;
475482
DEVELOPMENT_TEAM = V3TX3NWAPM;
476483
INFOPLIST_FILE = "idcheckio-sdk-sample-ios/Info.plist";
@@ -492,6 +499,7 @@
492499
buildSettings = {
493500
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
494501
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
502+
CODE_SIGN_ENTITLEMENTS = "idcheckio-sdk-sample-ios/idcheckio-sdk-sample-ios.entitlements";
495503
CODE_SIGN_STYLE = Automatic;
496504
DEVELOPMENT_TEAM = V3TX3NWAPM;
497505
INFOPLIST_FILE = "idcheckio-sdk-sample-ios/Info.plist";

idcheckio-sdk-sample-ios/idcheckio-sdk-sample-ios/Controllers/Sessions/AdvancedSessionViewController.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,15 @@ fileprivate extension AdvancedSessionViewController {
9090
coordinator?.showResult(.failure(error))
9191
return
9292
}
93+
//Manage errors that could occur during SDK startup.
94+
controller.startCompletion = { [weak self] (error) in
95+
if let error = error {
96+
self?.handleSdkResult(result: .failure(error))
97+
}
98+
}
9399
//Set the completion handler for both sdk events and sdk result
94-
controller.eventCompletion = handleSdkEvent
95-
controller.resultCompletion = handleSdkResult
100+
controller.eventCompletion = { [weak self] in self?.handleSdkEvent(interaction: $0, msg: $1) }
101+
controller.resultCompletion = { [weak self] in self?.handleSdkResult(result: $0) }
96102
registerInteraction()
97103
}
98104

idcheckio-sdk-sample-ios/idcheckio-sdk-sample-ios/Coordinator/OnlineFlowCoordinator.swift

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class OnlineFlowCoordinator: Coordinator {
1313
var childCoordinators = [Coordinator]()
1414
var navigationController: UINavigationController
1515
var parentCoordinator: Coordinator?
16-
16+
1717
fileprivate var onlineContext: OnlineContext?
1818
fileprivate var idResult: IdcheckioResult?
1919
fileprivate let configs: [SDKConfig] = [.id, .liveness]
@@ -26,11 +26,11 @@ class OnlineFlowCoordinator: Coordinator {
2626
}
2727
}
2828
}
29-
29+
3030
init(navigationController: UINavigationController) {
3131
self.navigationController = navigationController
3232
}
33-
33+
3434
func start() {
3535
activateSdk()
3636
}
@@ -59,7 +59,7 @@ class OnlineFlowCoordinator: Coordinator {
5959
}
6060

6161
fileprivate extension OnlineFlowCoordinator {
62-
62+
6363
func activateSdk() {
6464
//Activate the SDK with your licence file provided by ARIADNEXT
6565
Idcheckio.shared.activate(withLicenseFilename: "licence.axt", extractData: true, sdkEnvironment: .demo) { (error) in
@@ -70,7 +70,7 @@ fileprivate extension OnlineFlowCoordinator {
7070
}
7171
}
7272
}
73-
73+
7474
func showSessionController() {
7575
let storyboard = UIStoryboard(name: "Main", bundle: nil)
7676
if let vc = storyboard.instantiateViewController(withIdentifier: OnlineFlowViewController.identifier ) as? OnlineFlowViewController {
@@ -88,34 +88,14 @@ fileprivate extension OnlineFlowCoordinator {
8888
//Give online context from your previous session to link your liveness to the right CIS folder.
8989
sessionController.onlineContext = onlineContext
9090
sessionController.modalPresentationStyle = .fullScreen
91-
//Handle session result or error here
92-
sessionController.resultCompletion = { [weak self] (result) in
93-
guard let strongSelf = self else { return }
94-
//Dissmiss SDK controller when session is complete or an error occured
95-
DispatchQueue.main.async {
96-
strongSelf.navigationController.dismiss(animated: true, completion: {
97-
//Go back to portrait orientaion when the sdk has finished
98-
if let myDelegate = UIApplication.shared.delegate as? AppDelegate {
99-
myDelegate.supportedOrientation = .portrait
100-
}
101-
switch result {
102-
case .success(let result):
103-
guard let sessionResult = result else { return }
104-
//Save the online context to give to next sessions.
105-
self?.onlineContext = sessionResult.onlineContext
106-
switch sessionResult.document {
107-
case .identity:
108-
self?.idResult = result
109-
default:
110-
break
111-
}
112-
self?.index += 1
113-
case .failure(let error):
114-
strongSelf.parentCoordinator?.childDidFinish(strongSelf, result: .failure(error))
115-
}
116-
})
91+
//Manage errors that could occur during SDK startup.
92+
sessionController.startCompletion = { [weak self] (error) in
93+
if let error = error {
94+
self?.handleSdkResult(result: .failure(error))
11795
}
11896
}
97+
//Handle session result or error here
98+
sessionController.resultCompletion = { [weak self] in self?.handleSdkResult(result: $0) }
11999
//Enable all supported orientatons in App Delegate in order to launch the SDK in landscape if needed
120100
if let myDelegate = UIApplication.shared.delegate as? AppDelegate {
121101
myDelegate.supportedOrientation = .all
@@ -127,4 +107,31 @@ fileprivate extension OnlineFlowCoordinator {
127107
}
128108
}
129109
}
110+
111+
func handleSdkResult(result: Result<IdcheckioResult?, Error>) {
112+
//Dismiss SDK controller when session is complete or an error occured
113+
DispatchQueue.main.async {
114+
self.navigationController.dismiss(animated: true, completion: {
115+
//Go back to portrait orientaion when the sdk has finished
116+
if let myDelegate = UIApplication.shared.delegate as? AppDelegate {
117+
myDelegate.supportedOrientation = .portrait
118+
}
119+
switch result {
120+
case .success(let result):
121+
guard let sessionResult = result else { return }
122+
//Save the online context to give to next sessions.
123+
self.onlineContext = sessionResult.onlineContext
124+
switch sessionResult.document {
125+
case .identity:
126+
self.idResult = result
127+
default:
128+
break
129+
}
130+
self.index += 1
131+
case .failure(let error):
132+
self.parentCoordinator?.childDidFinish(self, result: .failure(error))
133+
}
134+
})
135+
}
136+
}
130137
}

idcheckio-sdk-sample-ios/idcheckio-sdk-sample-ios/Coordinator/SimpleCaptureCoordinator.swift

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,31 @@ fileprivate extension SimpleCaptureCoordinator {
6060
//Start the capture session
6161
let sessionController = IdcheckioViewController()
6262
sessionController.modalPresentationStyle = .fullScreen
63-
//Handle session result or error here
64-
sessionController.resultCompletion = { [weak self] (result) in
65-
guard let strongSelf = self else { return }
66-
//Dissmiss SDK controller when session is complete or an error occured
67-
DispatchQueue.main.async {
68-
strongSelf.navigationController.dismiss(animated: true, completion: {
69-
//Go back to portrait orientaion when the sdk has finished
70-
if let myDelegate = UIApplication.shared.delegate as? AppDelegate {
71-
myDelegate.supportedOrientation = .portrait
72-
}
73-
strongSelf.parentCoordinator?.childDidFinish(strongSelf, result: result)
74-
})
63+
//Manage errors that could occur during SDK startup.
64+
sessionController.startCompletion = { [weak self] (error) in
65+
if let error = error {
66+
self?.handleSdkResult(result: .failure(error))
7567
}
7668
}
69+
//Handle session result or error here
70+
sessionController.resultCompletion = { [weak self] in self?.handleSdkResult(result: $0) }
7771
//Enable all supported orientatons in App Delegate in order to launch the SDK in landscape if needed
7872
if let myDelegate = UIApplication.shared.delegate as? AppDelegate {
7973
myDelegate.supportedOrientation = .all
8074
}
8175
navigationController.present(sessionController, animated: true)
8276
}
77+
78+
func handleSdkResult(result: Result<IdcheckioResult?, Error>) {
79+
//Dissmiss SDK controller when session is complete or an error occured
80+
DispatchQueue.main.async {
81+
self.navigationController.dismiss(animated: true, completion: {
82+
//Go back to portrait orientaion when the sdk has finished
83+
if let myDelegate = UIApplication.shared.delegate as? AppDelegate {
84+
myDelegate.supportedOrientation = .portrait
85+
}
86+
self.parentCoordinator?.childDidFinish(self, result: result)
87+
})
88+
}
89+
}
8390
}

idcheckio-sdk-sample-ios/idcheckio-sdk-sample-ios/Info.plist

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,12 @@
4141
<string>UIInterfaceOrientationLandscapeLeft</string>
4242
<string>UIInterfaceOrientationLandscapeRight</string>
4343
</array>
44+
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
45+
<array>
46+
<string>A0000002471001</string>
47+
<string>00000000000000</string>
48+
</array>
49+
<key>NFCReaderUsageDescription</key>
50+
<string>NFC is needed to scan your document chip</string>
4451
</dict>
4552
</plist>

idcheckio-sdk-sample-ios/idcheckio-sdk-sample-ios/SDKConfig.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum SDKConfig: String {
4848
params.side2Extraction = extractionSide2
4949
params.orientation = .portrait
5050
let integrityCheck = IntegrityCheck()
51-
integrityCheck.readEmrtd = true
51+
integrityCheck.readEmrtd = true // Need `Near Field Communication Tag Reading` (NFC) capability.
5252
params.integrityCheck = integrityCheck
5353
case .selfie:
5454
params.documentType = .selfie
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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>com.apple.developer.nfc.readersession.formats</key>
6+
<array>
7+
<string>NDEF</string>
8+
<string>TAG</string>
9+
</array>
10+
</dict>
11+
</plist>

0 commit comments

Comments
 (0)