11@import UIKit;
22#import " RNRegulaDocumentReader.h"
33
4+ NSString * videoEncoderCompletionEvent = @" videoEncoderCompletionEvent" ;
5+ NSString * completionEvent = @" completionEvent" ;
6+ NSString * prepareDatabaseProgressChangeEvent = @" prepareDatabaseProgressChangeEvent" ;
47NSString * rfidNotificationCompletionEvent = @" rfidNotificationCompletionEvent" ;
58NSString * paCertificateCompletionEvent = @" paCertificateCompletionEvent" ;
69NSString * taCertificateCompletionEvent = @" taCertificateCompletionEvent" ;
@@ -41,7 +44,15 @@ @implementation RNRegulaDocumentReader
4144RCT_EXPORT_MODULE ();
4245
4346- (NSArray <NSString*>*)supportedEvents {
44- return @[@" prepareDatabaseProgressChangeEvent" , @" completionEvent" , @" videoEncoderCompletionEvent" ];
47+ return @[
48+ prepareDatabaseProgressChangeEvent,
49+ completionEvent,
50+ videoEncoderCompletionEvent,
51+ rfidNotificationCompletionEvent,
52+ paCertificateCompletionEvent,
53+ taCertificateCompletionEvent,
54+ taSignatureCompletionEvent
55+ ];
4556}
4657
4758static NSNumber * _databasePercentageDownloaded;
@@ -58,36 +69,36 @@ - (void)result:(NSString*)message :(Callback)callback {
5869-(void (^_Nullable)(NSProgress * _Nonnull progress))getProgressHandler : (Callback)successCallback : (Callback)errorCallback {
5970 return ^(NSProgress * _Nonnull progress) {
6071 if (RNRegulaDocumentReader.databasePercentageDownloaded != [NSNumber numberWithDouble: progress.fractionCompleted * 100 ]){
61- [self sendEventWithName: @" prepareDatabaseProgressChangeEvent" body: @{@" msg" : [NSString stringWithFormat: @" %.1f " , progress.fractionCompleted * 100 ]}];
72+ [self sendEventWithName: prepareDatabaseProgressChangeEvent body: @{@" msg" : [NSString stringWithFormat: @" %.1f " , progress.fractionCompleted * 100 ]}];
6273 [RNRegulaDocumentReader setDatabasePercentageDownloaded: [NSNumber numberWithDouble: progress.fractionCompleted * 100 ]];
6374 }
6475 };
6576}
6677
6778-(RGLDocumentReaderCompletion _Nonnull)getCompletion {
6879 return ^(RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error) {
69- [self sendEventWithName: @" completionEvent" body: @{@" msg" : [RGLWJSONConstructor dictToString: [RGLWJSONConstructor generateCompletion: [RGLWJSONConstructor generateDocReaderAction: action] :results :error :nil ]]}];
80+ [self sendEventWithName: completionEvent body: @{@" msg" : [RGLWJSONConstructor dictToString: [RGLWJSONConstructor generateCompletion: [RGLWJSONConstructor generateDocReaderAction: action] :results :error :nil ]]}];
7081 };
7182}
7283
7384-(RGLRFIDProcessCompletion _Nonnull)getRFIDCompletion {
7485 return ^(RGLRFIDCompleteAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error, RGLRFIDErrorCodes errorCode) {
75- [self sendEventWithName: @" completionEvent" body: @{@" msg" : [RGLWJSONConstructor dictToString: [RGLWJSONConstructor generateCompletion: [RGLWJSONConstructor generateRFIDCompleteAction: action] :results :error :nil ]]}];
86+ [self sendEventWithName: completionEvent body: @{@" msg" : [RGLWJSONConstructor dictToString: [RGLWJSONConstructor generateCompletion: [RGLWJSONConstructor generateRFIDCompleteAction: action] :results :error :nil ]]}];
7687 };
7788}
7889
7990-(RGLRFIDNotificationCallback _Nonnull)getRFIDNotificationCallback {
8091 return ^(RGLRFIDNotificationAction notificationAction, RGLRFIDNotify* _Nullable notify) {
81- [self sendEventWithName: @" completionEvent" body: @{@" msg" : [RGLWJSONConstructor dictToString: [RGLWJSONConstructor generateCompletion: [RGLWJSONConstructor generateRFIDNotificationAction: notificationAction] :nil :nil :notify]]}];
92+ [self sendEventWithName: completionEvent body: @{@" msg" : [RGLWJSONConstructor dictToString: [RGLWJSONConstructor generateCompletion: [RGLWJSONConstructor generateRFIDNotificationAction: notificationAction] :nil :nil :notify]]}];
8293 };
8394}
8495
8596- (void )didFinishRecordingToFile : (NSURL *)fileURL {
86- [self sendEventWithName: @" videoEncoderCompletionEvent" body: @{@" msg" : [RGLWJSONConstructor dictToString: [RGLWJSONConstructor generateVideoEncoderCompletion: fileURL :nil ]]}];
97+ [self sendEventWithName: videoEncoderCompletionEvent body: @{@" msg" : [RGLWJSONConstructor dictToString: [RGLWJSONConstructor generateVideoEncoderCompletion: fileURL :nil ]]}];
8798}
8899
89100- (void )didFailWithError : (NSError *)error {
90- [self sendEventWithName: @" videoEncoderCompletionEvent" body: @{@" msg" : [RGLWJSONConstructor dictToString: [RGLWJSONConstructor generateVideoEncoderCompletion: nil :error]]}];
101+ [self sendEventWithName: videoEncoderCompletionEvent body: @{@" msg" : [RGLWJSONConstructor dictToString: [RGLWJSONConstructor generateVideoEncoderCompletion: nil :error]]}];
91102}
92103
93104- (void )onRequestPACertificatesWithSerial : (NSData *)serialNumber issuer : (RGLPAResourcesIssuer *)issuer callback : (RGLRFIDCertificatesCallback)callback {
0 commit comments