uqudosdk-capacitor 2.2.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.
@@ -0,0 +1,518 @@
1
+ #import <Capacitor/Capacitor.h>
2
+ #import <UqudoSDK/UqudoSDK.h>
3
+ #import "MyTracer.h"
4
+
5
+ @interface UqudoId : CAPPlugin<UQBuilderControllerDelegate> {}
6
+ @property CAPPluginCall * pluginCall;
7
+ @end
8
+
9
+ @implementation UqudoId
10
+ @synthesize pluginCall;
11
+
12
+ - (void)init:(CAPPluginCall*)call {
13
+ MyTracer *tracer = [[MyTracer alloc] init];
14
+ tracer.bridge = self.bridge;
15
+ [[UQBuilderController alloc] initWithTracer:tracer];
16
+ }
17
+
18
+ - (void)setLocale:(CAPPluginCall*)call {
19
+ NSString* locale = call.options[@"value"];
20
+ NSLog(@"%@", locale);
21
+ [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:locale, nil]forKey:@"AppleLanguages"];
22
+ [[NSUserDefaults standardUserDefaults] synchronize];
23
+ }
24
+
25
+ - (void)enroll:(CAPPluginCall*)call
26
+ {
27
+ self.pluginCall = call;
28
+ NSString* enrollObj = call.options[@"value"];
29
+ @try {
30
+ if (enrollObj != nil && [enrollObj length] > 0) {
31
+ NSData* data = [enrollObj dataUsingEncoding:NSUTF8StringEncoding];
32
+ id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
33
+
34
+ NSString* authorizationToken = json[@"authorizationToken"];
35
+ NSString* nonce = json[@"nonce"];
36
+ NSDictionary* documentList = json[@"documentList"];
37
+ NSDictionary* facialRecognitionSpecification = json[@"facialRecognitionSpecification"];
38
+ NSDictionary* backgroundCheckConfiguration = json[@"backgroundCheckConfiguration"];
39
+ NSDictionary* lookupConfiguration = json[@"lookupConfiguration"];
40
+
41
+ // Config enrollment builder
42
+ UQEnrollmentBuilder *enrollmentBuilder = [[UQEnrollmentBuilder alloc] init];
43
+ NSString* sessionId = json[@"sessionId"];
44
+ if (sessionId && sessionId.length > 0) {
45
+ [enrollmentBuilder setSessionID:sessionId];
46
+ }
47
+ NSString* userIdentifier = json[@"userIdentifier"];
48
+ if (userIdentifier && userIdentifier.length > 0) {
49
+ NSUUID *uuid = [[NSUUID UUID] initWithUUIDString:userIdentifier];
50
+ [enrollmentBuilder setUserIdentifier:uuid];
51
+ }
52
+ if (json[@"isRootedDeviceAllowed"]) {
53
+ enrollmentBuilder.isRootedDeviceAllowed = [[json valueForKey:@"isRootedDeviceAllowed"] boolValue];
54
+ }
55
+ if (json[@"isReturnDataForIncompleteSession"]) {
56
+ enrollmentBuilder.returnDataForIncompleteSession = [[json valueForKey:@"isReturnDataForIncompleteSession"] boolValue];
57
+ }
58
+ if (facialRecognitionSpecification) {
59
+ // Enable help page for face recognition
60
+ enrollmentBuilder.enableFacialRecognition = TRUE;
61
+
62
+ // Enable enroll face option
63
+ if (facialRecognitionSpecification[@"enrollFace"]) {
64
+ enrollmentBuilder.enrollFace = [[facialRecognitionSpecification valueForKey:@"enrollFace"] boolValue];
65
+ }
66
+
67
+ if (facialRecognitionSpecification[@"scanMinimumMatchLevel"]) {
68
+ enrollmentBuilder.scanMinimumMatchLevel = [[facialRecognitionSpecification valueForKey:@"scanMinimumMatchLevel"] integerValue];
69
+ }
70
+
71
+ if (facialRecognitionSpecification[@"readMinimumMatchLevel"]) {
72
+ enrollmentBuilder.readMinimumMatchLevel = [[facialRecognitionSpecification valueForKey:@"readMinimumMatchLevel"] integerValue];
73
+ }
74
+
75
+ if (facialRecognitionSpecification[@"maxAttempts"]) {
76
+ int maxAttempts = [[facialRecognitionSpecification valueForKey:@"maxAttempts"] intValue];
77
+ if (maxAttempts > 0) {
78
+ enrollmentBuilder.facialRecognitionMaxAttempts = maxAttempts;
79
+ }
80
+ }
81
+
82
+ }
83
+
84
+ if(lookupConfiguration){
85
+ NSMutableArray *lookupDocumentTypes = [[NSMutableArray alloc] init];
86
+ if(lookupConfiguration[@"documentList"]){
87
+ for (NSString *document in lookupConfiguration[@"documentList"]) {
88
+ UQDocumentConfig *documentConfig = [[UQDocumentConfig alloc] initWithDocumentTypeName:document];
89
+ [lookupDocumentTypes addObject:[NSNumber numberWithInteger:[documentConfig documentType]]];
90
+ }
91
+ }
92
+ if (lookupDocumentTypes.count) {
93
+ [enrollmentBuilder enableLookup:lookupDocumentTypes];
94
+ }
95
+ else {
96
+ [enrollmentBuilder enableLookup];
97
+ }
98
+ }
99
+
100
+ if (backgroundCheckConfiguration) {
101
+ BOOL isDisableConsent = FALSE;
102
+ if (backgroundCheckConfiguration[@"disableConsent"]) {
103
+ isDisableConsent = [[backgroundCheckConfiguration valueForKey:@"disableConsent"] boolValue];
104
+ }
105
+ BOOL isMonitoringEnabled = FALSE;
106
+ if (backgroundCheckConfiguration[@"monitoringEnabled"]) {
107
+ isMonitoringEnabled = [[backgroundCheckConfiguration valueForKey:@"monitoringEnabled"] boolValue];
108
+ }
109
+ BackgroundCheckType type = RDC;
110
+ if (backgroundCheckConfiguration[@"backgroundCheckType"]) {
111
+ type = [backgroundCheckConfiguration[@"backgroundCheckType"] isEqual: @"RDC"] ? RDC : DOW_JONES;
112
+ }
113
+ BOOL isSkipView = FALSE;
114
+ if (backgroundCheckConfiguration[@"skipView"]) {
115
+ isSkipView = [[backgroundCheckConfiguration valueForKey:@"skipView"] boolValue];
116
+ }
117
+ [enrollmentBuilder enableBackgroundCheck:isDisableConsent type:type monitoring:isMonitoringEnabled skipView:isSkipView];
118
+ }
119
+ for (NSDictionary *document in documentList) {
120
+ NSString* documentType = document[@"documentType"];
121
+ UQDocumentConfig *documentObject = [[UQDocumentConfig alloc] initWithDocumentTypeName:documentType];
122
+ if(documentObject.documentType == UNSPECIFY){
123
+ continue;
124
+ }
125
+
126
+ UQScanConfig *scanConfig = [[UQScanConfig alloc] init];
127
+ if (document[@"isHelpPageDisabled"]) {
128
+ scanConfig.disableHelpPage = [[document valueForKey:@"isHelpPageDisabled"] boolValue];
129
+ }
130
+ if (document[@"faceScanMinimumMatchLevel"]) {
131
+ scanConfig.faceMinimumMatchLevel = [[document valueForKey:@"faceScanMinimumMatchLevel"] intValue];
132
+ }
133
+ if (document[@"minimumAge"]) {
134
+ int minimumAge = [[document valueForKey:@"minimumAge"] intValue];
135
+ if (minimumAge > 0) {
136
+ documentObject.enableAgeVerification = minimumAge;
137
+ }
138
+ }
139
+ BOOL isEnabelFrontSideReview = false;
140
+ BOOL isEnabelBackSideReview = false;
141
+
142
+ if (document[@"isFrontSideReviewEnabled"]) {
143
+ isEnabelFrontSideReview = [[document valueForKey:@"isFrontSideReviewEnabled"] boolValue];
144
+ }
145
+ if (document[@"isBackSideReviewEnabled"]) {
146
+ isEnabelBackSideReview = [[document valueForKey:@"isBackSideReviewEnabled"] boolValue];
147
+ }
148
+ [scanConfig enableScanReview:isEnabelFrontSideReview backSide:isEnabelBackSideReview];
149
+ if (document[@"isUploadEnabled"]) {
150
+ scanConfig.enableUpload = [[document valueForKey:@"isUploadEnabled"] boolValue];
151
+ }
152
+ documentObject.scan = scanConfig;
153
+
154
+ if (document[@"isExpiredDocumentValidateDisabled"]) {
155
+ documentObject.disableExpiryValidation = [[document valueForKey:@"isExpiredDocumentValidateDisabled"] boolValue];
156
+ }
157
+
158
+ if (document[@"readingConfiguration"]) {
159
+ if (@available(iOS 13, *)) {
160
+ NSDictionary *readingConfiguration = document[@"readingConfiguration"];
161
+
162
+ UQReadingConfig *readConfig = [[UQReadingConfig alloc] init];
163
+ readConfig.enableReading = TRUE;
164
+ if (readingConfiguration[@"forceReading"]) {
165
+ [readConfig forceReading:[[readingConfiguration valueForKey:@"forceReading"] boolValue]];
166
+ }
167
+ if (readingConfiguration[@"forceReadingIfSupported"]) {
168
+ [readConfig forceReadingIfSupported:[[readingConfiguration valueForKey:@"forceReadingIfSupported"] boolValue]];
169
+ }
170
+ if (document[@"faceReadMinimumMatchLevel"]) {
171
+ readConfig.faceMinimumMatchLevel = [[document valueForKey:@"faceReadMinimumMatchLevel"] intValue];
172
+ }
173
+ if (readingConfiguration[@"timeoutInSeconds"]) {
174
+ int timeoutInSeconds = [[readingConfiguration valueForKey:@"timeoutInSeconds"] intValue];
175
+ if (timeoutInSeconds > 0) {
176
+ readConfig.forceReadingTimeout = timeoutInSeconds;
177
+ }
178
+ }
179
+
180
+ documentObject.reading = readConfig;
181
+ }
182
+ }
183
+
184
+ [enrollmentBuilder add:documentObject];
185
+ }
186
+ // Add enrollment to builder
187
+ UQBuilderController *builderController = [UQBuilderController defaultBuilder];
188
+ builderController.delegate = self;
189
+ [builderController setEnrollment:enrollmentBuilder];
190
+ // set appearanceMode to builder
191
+ NSInteger appearanceMode = SYSTEM;
192
+ if (json[@"appearanceMode"]) {
193
+ if ([json[@"appearanceMode"] isEqualToString:@"LIGHT"]) {
194
+ appearanceMode = LIGHT;
195
+ } else if ([json[@"appearanceMode"] isEqualToString:@"DARK"]) {
196
+ appearanceMode = DARK;
197
+ }
198
+ }
199
+ [builderController setAppearanceMode:appearanceMode];
200
+
201
+
202
+ // // Start enrollment flow
203
+ // // accessToken reuire, if no token the UQExceptionInvalidToken will throw
204
+ dispatch_async(dispatch_get_main_queue(), ^(void) {
205
+ UIWindow *window = [UIApplication sharedApplication].keyWindow;
206
+ UIViewController *rootViewController = window.rootViewController;
207
+ builderController.appViewController = rootViewController;
208
+ [builderController performEnrollmentWithToken:authorizationToken optionNonce:nonce];
209
+ });
210
+ } else {
211
+ UQSessionStatus *status =[[UQSessionStatus alloc] init];
212
+ status.statusCode = UNEXPECTED_ERROR;
213
+ status.message = @"Expected enrollment object as argument.";
214
+ status.statusTask = -1;
215
+ [self sendPluginError:status];
216
+ }
217
+ }
218
+ @catch (NSException *exception) {
219
+ NSLog(@"%@", exception.callStackSymbols);
220
+ UQSessionStatus *status =[[UQSessionStatus alloc] init];
221
+ status.statusCode = UNEXPECTED_ERROR;
222
+ status.message = exception.reason;
223
+ status.statusTask = -1;
224
+ [self sendPluginError:status];
225
+ }
226
+ }
227
+
228
+ - (void) didEnrollmentFailWithError:(NSError *)error {
229
+ NSLog(@"Error %ld %@", (long)error.code, error.localizedDescription);
230
+ UQSessionStatus *status =[[UQSessionStatus alloc] init];
231
+ status.statusCode = UNEXPECTED_ERROR;
232
+ status.message = error.localizedDescription;
233
+ status.statusTask = -1;
234
+ [self sendPluginError:status];
235
+ }
236
+
237
+ - (void) didEnrollmentCompleteWithInfo:(NSString *)jwsString {
238
+ CAPPluginCallResult *result = [[CAPPluginCallResult alloc]init:@{@"value":jwsString}];
239
+ pluginCall.successHandler(result, pluginCall);
240
+ }
241
+
242
+ - (void) didEnrollmentIncompleteWithStatus:(UQSessionStatus *)status {
243
+ [self sendPluginError:status];
244
+ }
245
+
246
+ - (void)recover:(CAPPluginCall*)call
247
+ {
248
+ self.pluginCall = call;
249
+ NSString* recoverObj = call.options[@"value"];
250
+
251
+ @try {
252
+ if (recoverObj != nil && [recoverObj length] > 0) {
253
+ NSData *data = [recoverObj dataUsingEncoding:NSUTF8StringEncoding];
254
+ id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
255
+
256
+ // Config account recovery builder
257
+ UQAccountRecoveryBuilder *accountRecoveryBuilder = [[UQAccountRecoveryBuilder alloc] init];
258
+ accountRecoveryBuilder.authorizationToken = json[@"token"];
259
+ accountRecoveryBuilder.enrollmentIdentifier = json[@"enrollmentIdentifier"];
260
+ accountRecoveryBuilder.nonce = json[@"nonce"];
261
+ if (json[@"isRootedDeviceAllowed"]) {
262
+ accountRecoveryBuilder.isRootedDeviceAllowed = [[json valueForKey:@"isRootedDeviceAllowed"] boolValue];
263
+ }
264
+ if (json[@"minimumMatchLevel"]) {
265
+ accountRecoveryBuilder.minimumMatchLevel = [[json valueForKey:@"minimumMatchLevel"] intValue];
266
+ }
267
+
268
+ if (json[@"maxAttempts"]) {
269
+ int maxAttempts = [[json valueForKey:@"maxAttempts"] intValue];
270
+ if (maxAttempts > 0) {
271
+ accountRecoveryBuilder.maxAttempts = maxAttempts;
272
+ }
273
+ }
274
+
275
+ if (json[@"isReturnDataForIncompleteSession"]) {
276
+ accountRecoveryBuilder.returnDataForIncompleteSession = [[json valueForKey:@"isReturnDataForIncompleteSession"] boolValue];
277
+ }
278
+
279
+ UQBuilderController *builderController = [UQBuilderController defaultBuilder];
280
+ builderController.delegate = self;
281
+ [builderController setAccountRecovery:accountRecoveryBuilder];
282
+ NSInteger appearanceMode = SYSTEM;
283
+ if (json[@"appearanceMode"]) {
284
+ if ([json[@"appearanceMode"] isEqualToString:@"LIGHT"]) {
285
+ appearanceMode = LIGHT;
286
+ } else if ([json[@"appearanceMode"] isEqualToString:@"DARK"]) {
287
+ appearanceMode = DARK;
288
+ }
289
+ }
290
+ [builderController setAppearanceMode:appearanceMode];
291
+
292
+
293
+ dispatch_async(dispatch_get_main_queue(), ^(void) {
294
+ UIWindow *window = [UIApplication sharedApplication].keyWindow;
295
+ UIViewController *rootViewController = window.rootViewController;
296
+ builderController.appViewController = rootViewController;
297
+ [builderController performAccountRecovery];
298
+ });
299
+ } else {
300
+ UQSessionStatus *status =[[UQSessionStatus alloc] init];
301
+ status.statusCode = UNEXPECTED_ERROR;
302
+ status.message = @"Expected account recovery object as argument.";
303
+ status.statusTask = -1;
304
+ [self sendPluginError:status];
305
+ }
306
+ }
307
+ @catch (NSException *exception) {
308
+ NSLog(@"%@", exception.callStackSymbols);
309
+ UQSessionStatus *status =[[UQSessionStatus alloc] init];
310
+ status.statusCode = UNEXPECTED_ERROR;
311
+ status.message = exception.reason;
312
+ status.statusTask = -1;
313
+ [self sendPluginError:status];
314
+ }
315
+ }
316
+
317
+ - (void)didAccountRecoveryCompleteWithInfo:(nonnull NSString *)jwsString {
318
+ CAPPluginCallResult *result = [[CAPPluginCallResult alloc]init:@{@"value":jwsString}];
319
+ pluginCall.successHandler(result, pluginCall);
320
+ }
321
+
322
+ - (void)didAccountRecoveryFailWithError:(nonnull NSError *)error {
323
+ NSLog(@"Error %ld %@", (long)error.code, error.localizedDescription);
324
+ UQSessionStatus *status =[[UQSessionStatus alloc] init];
325
+ status.statusCode = UNEXPECTED_ERROR;
326
+ status.message = error.localizedDescription;
327
+ status.statusTask = -1;
328
+ [self sendPluginError:status];
329
+ }
330
+
331
+ - (void)didAccountRecoveryIncompleteWithStatus:(UQSessionStatus *)status {
332
+ [self sendPluginError:status];
333
+ }
334
+
335
+ - (void)sendPluginError:(UQSessionStatus *)status {
336
+ NSString *code = nil;
337
+ switch (status.statusCode) {
338
+ case USER_CANCEL:
339
+ code = @"USER_CANCEL";
340
+ break;
341
+ case SESSION_EXPIRED:
342
+ code = @"SESSION_EXPIRED";
343
+ break;
344
+ case UNEXPECTED_ERROR:
345
+ code = @"UNEXPECTED_ERROR";
346
+ break;
347
+ case SESSION_INVALIDATED_CHIP_VALIDATION_FAILED:
348
+ code = @"SESSION_INVALIDATED_CHIP_VALIDATION_FAILED";
349
+ break;
350
+ case SESSION_INVALIDATED_READING_NOT_SUPPORTED:
351
+ code = @"SESSION_INVALIDATED_READING_NOT_SUPPORTED";
352
+ break;
353
+ case SESSION_INVALIDATED_READING_INVALID_DOCUMENT:
354
+ code = @"SESSION_INVALIDATED_READING_INVALID_DOCUMENT";
355
+ break;
356
+ case SESSION_INVALIDATED_FACE_RECOGNITION_TOO_MANY_ATTEMPTS:
357
+ code = @"SESSION_INVALIDATED_FACE_RECOGNITION_TOO_MANY_ATTEMPTS";
358
+ break;
359
+ }
360
+ NSString *task = nil;
361
+ switch (status.statusTask) {
362
+ case SCAN:
363
+ task = @"SCAN";
364
+ break;
365
+ case READING:
366
+ task = @"READING";
367
+ break;
368
+ case FACE:
369
+ task = @"FACE";
370
+ break;
371
+ case BACKGROUND_CHECK:
372
+ task = @"BACKGROUND_CHECK";
373
+ break;
374
+ }
375
+ NSMutableDictionary *error = [[NSMutableDictionary alloc]init];
376
+ [error setValue:code forKey:@"code"];
377
+ [error setValue:status.message forKey:@"message"];
378
+ [error setValue:task forKey:@"task"];
379
+ [error setValue:status.data forKey:@"data"];
380
+
381
+ NSError *err = nil;
382
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:error options:NSJSONWritingPrettyPrinted error:&err];
383
+
384
+ NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
385
+ CAPPluginCallError *capError = [[CAPPluginCallError alloc]init:@"" code:jsonString error:nil data:@{}];
386
+ pluginCall.errorHandler(capError);
387
+ // pluginCall.reject(jsonString, nil, nil);
388
+ }
389
+
390
+ - (void)faceSession:(CAPPluginCall*)call
391
+ {
392
+ self.pluginCall = call;
393
+ NSString* recoverObj = call.options[@"value"];
394
+
395
+ @try {
396
+ if (recoverObj != nil && [recoverObj length] > 0) {
397
+ NSData *data = [recoverObj dataUsingEncoding:NSUTF8StringEncoding];
398
+ id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
399
+
400
+ UQFaceSessionBuilder *faceSessionBuilder = [[UQFaceSessionBuilder alloc] init];
401
+ faceSessionBuilder.authorizationToken = json[@"token"];
402
+ faceSessionBuilder.sessionId = json[@"sessionId"];
403
+ faceSessionBuilder.nonce = json[@"nonce"];
404
+ if (json[@"isRootedDeviceAllowed"]) {
405
+ faceSessionBuilder.isRootedDeviceAllowed = [[json valueForKey:@"isRootedDeviceAllowed"] boolValue];
406
+ }
407
+ if (json[@"minimumMatchLevel"]) {
408
+ faceSessionBuilder.minimumMatchLevel = [[json valueForKey:@"minimumMatchLevel"] intValue];
409
+ }
410
+
411
+ if (json[@"maxAttempts"]) {
412
+ int maxAttempts = [[json valueForKey:@"maxAttempts"] intValue];
413
+ if (maxAttempts > 0) {
414
+ faceSessionBuilder.maxAttempts = maxAttempts;
415
+ }
416
+ }
417
+
418
+ if (json[@"isReturnDataForIncompleteSession"]) {
419
+ faceSessionBuilder.returnDataForIncompleteSession = [[json valueForKey:@"isReturnDataForIncompleteSession"] boolValue];
420
+ }
421
+
422
+ UQBuilderController *builderController = [UQBuilderController defaultBuilder];
423
+ builderController.delegate = self;
424
+ UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
425
+ builderController.appViewController = rootViewController;
426
+ [builderController setFaceSession:faceSessionBuilder];
427
+
428
+ NSInteger appearanceMode = SYSTEM;
429
+ if (json[@"appearanceMode"]) {
430
+ if ([json[@"appearanceMode"] isEqualToString:@"LIGHT"]) {
431
+ appearanceMode = LIGHT;
432
+ } else if ([json[@"appearanceMode"] isEqualToString:@"DARK"]) {
433
+ appearanceMode = DARK;
434
+ }
435
+ }
436
+ [builderController setAppearanceMode:appearanceMode];
437
+
438
+ [builderController performFaceSession];
439
+ } else {
440
+ UQSessionStatus *status =[[UQSessionStatus alloc] init];
441
+ status.statusCode = UNEXPECTED_ERROR;
442
+ status.message = @"Expected face session configuration as argument.";
443
+ status.statusTask = -1;
444
+ [self sendPluginError:status];
445
+ }
446
+ }
447
+ @catch (NSException *exception) {
448
+ NSLog(@"%@", exception.callStackSymbols);
449
+ UQSessionStatus *status =[[UQSessionStatus alloc] init];
450
+ status.statusCode = UNEXPECTED_ERROR;
451
+ status.message = exception.reason;
452
+ status.statusTask = -1;
453
+ [self sendPluginError:status];
454
+
455
+ }
456
+ }
457
+
458
+ - (void)didFaceSessionCompleteWithInfo:(nonnull NSString *)jwsString {
459
+ CAPPluginCallResult *result = [[CAPPluginCallResult alloc]init:@{@"value":jwsString}];
460
+ pluginCall.successHandler(result, pluginCall);
461
+ }
462
+
463
+ - (void)didFaceSessionFailWithError:(nonnull NSError *)error {
464
+ NSLog(@"Error %ld %@", (long)error.code, error.localizedDescription);
465
+ UQSessionStatus *status =[[UQSessionStatus alloc] init];
466
+ status.statusCode = UNEXPECTED_ERROR;
467
+ status.message = error.localizedDescription;
468
+ status.statusTask = -1;
469
+ [self sendPluginError:status];
470
+ }
471
+
472
+ - (void)didFaceSessionIncompleteWithStatus:(UQSessionStatus *)status {
473
+ [self sendPluginError:status];
474
+ }
475
+ @end
476
+
477
+ @implementation MyTracer
478
+
479
+ - (void)trace:(UQTrace *)trace {
480
+ NSMutableDictionary* parameters = [[NSMutableDictionary alloc] init];
481
+
482
+ if(nil != trace.sessionId){
483
+ [parameters setValue:trace.sessionId forKey:@"sessionId"];
484
+ }
485
+ [parameters setValue:trace.event->name forKey:@"event"];
486
+ [parameters setValue:trace.status->name forKey:@"status"];
487
+
488
+ NSString *timeStamp = [self timeStamp:trace.timestamp];
489
+ [parameters setValue:timeStamp forKey:@"timestamp"];
490
+
491
+ if (TP_NULL != trace.page) {
492
+ [parameters setValue:trace.page->name forKey:@"page"];
493
+ }
494
+ if (TSC_NULL != trace.statusCode) {
495
+ [parameters setValue:trace.statusCode->name forKey:@"statusCode"];
496
+ }
497
+ if (trace.documentType != UNSPECIFY) {
498
+ UQDocumentConfig *document = [[UQDocumentConfig alloc] initWithDocumentType:trace.documentType];
499
+ [parameters setValue:document.documentName forKey:@"documentType"];
500
+ }
501
+ if (trace.statusMessage) {
502
+ [parameters setValue:trace.statusMessage forKey:@"statusMessage"];
503
+ }
504
+
505
+ NSError *err = nil;
506
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:NSJSONWritingPrettyPrinted error:&err];
507
+
508
+ NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
509
+ [self.bridge triggerWindowJSEventWithEventName:@"TraceEvent" data:jsonString];
510
+ }
511
+
512
+ - (NSString *)timeStamp:(NSDate *)currentDate {
513
+ return [NSDateFormatter localizedStringFromDate:currentDate
514
+ dateStyle:NSDateFormatterFullStyle
515
+ timeStyle:NSDateFormatterFullStyle];
516
+ }
517
+
518
+ @end
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,12 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(UqudoId, "UqudoId",
7
+ CAP_PLUGIN_METHOD(init, CAPPluginReturnPromise);
8
+ CAP_PLUGIN_METHOD(setLocale, CAPPluginReturnPromise);
9
+ CAP_PLUGIN_METHOD(enroll, CAPPluginReturnPromise);
10
+ CAP_PLUGIN_METHOD(recover, CAPPluginReturnPromise);
11
+ CAP_PLUGIN_METHOD(faceSession, CAPPluginReturnPromise);
12
+ )
@@ -0,0 +1,11 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(UqudoIdPlugin)
9
+ public class UqudoIdPlugin: CAPPlugin {
10
+
11
+ }
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "uqudosdk-capacitor",
3
+ "version": "2.2.1",
4
+ "description": "Capacitor plugin for UqudoSDK",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "homepage": "https://uqudo.com",
10
+ "files": [
11
+ "android/src/main/",
12
+ "android/build.gradle",
13
+ "dist/",
14
+ "ios/Plugin/",
15
+ "UqudosdkCapacitor.podspec"
16
+ ],
17
+ "author": "uqudo",
18
+ "license": "MIT",
19
+ "capacitor": {
20
+ "ios": {
21
+ "src": "ios"
22
+ },
23
+ "android": {
24
+ "src": "android"
25
+ }
26
+ }
27
+ }