react-native-okaycam 2.0.5 → 3.0.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.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### Android
6
6
 
7
- - minSdkVersion >= 21
7
+ - minSdkVersion >= 30
8
8
 
9
9
  ### iOS
10
10
 
@@ -13,7 +13,27 @@
13
13
 
14
14
  ## Getting started
15
15
 
16
- `$ react-native install react-native-okaycam`
16
+ `$ yarn add react-native-okaycam@3.x.x`
17
+
18
+ ### Android
19
+
20
+ 1. Navigate to `android` folder
21
+ 2. Add following snippet in the root `build.gradle` file:
22
+
23
+ ```
24
+ allprojects {
25
+ repositories {
26
+ maven {
27
+ url "https://innov8tif-okaycam.firebaseapp.com"
28
+ content {
29
+ includeGroup "com.innov8tif.xendity"
30
+ }
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ 3. Sync gradle
17
37
 
18
38
  ### iOS
19
39
 
@@ -86,41 +106,42 @@ const license = Platform.select({
86
106
 
87
107
  ### Configuration
88
108
 
89
- | - | Property name | Description | Default value |
90
- | ------------------------------ | ---------------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
91
- | - | torchBtnEnabled | to show torch button. If set to true, it will only be shown if onFlash from captureConfig is set to false. | false |
92
- | - | crop | crop the frame area | false |
93
- | - | width | width to resize the image | original width |
94
- | - | imageQuality | quality of image | 1.0 (range from 0.0 to 1.0) |
95
- | frame | size | size of the frame (width and height) | 90% of screen width and height is scaled proportionally according to card ratio |
96
- | frame | color | color of the frame | #ffffff |
97
- | frame | content | content of the frame (able to display svg file within the frame for guidance | null |
98
- | - | showOverlay | transparent black overlay | true |
99
- | topLabel | text | text of the top label | ""(empty string) |
100
- | topLabel | color | color of the top label | #ffffff |
101
- | topLabel | size | text size of the top label | 20 |
102
- | bottomLabel | text | text of the bottom label | ""(empty string) |
103
- | bottomLabel | color | color of the bottom label | #ffffff |
104
- | bottomLabel | size | text size of the bottom label | 20 |
105
- | timer | backgroundColor | background of the count down timer | #ffa500 |
106
- | timer | textColor | text color of the count down timer | #ffffff |
107
- | confirmBtnConfig | backgroundColor | background color of the confirm button | #ffa500 |
108
- | confirmBtnConfig | contentColor | content color of the confirm button | #ffffff |
109
- | retakeBtnConfig | backgroundColor | background color of the retake button | #ffa500 |
110
- | retakeBtnConfig | contentColor | content color of the retake button | #ffffff |
111
- | - | captureBtnColor | color of the capture button | #ffffff |
112
- | - | firstPhotoConfig | config for the first capture | delay:0s,onFlash:false,outputPath: null |
113
- | - | secondPhotoConfig | config for the second capture | null |
114
- | preview | title | title on preview screen | ""(empty string) |
115
- | preview | refImg | ref image on preview screen | null |
116
- | preview | instruction1 | instruction on preview screen | ""(empty string) |
117
- | preview | instruction2 | instruction on preview screen | ""(empty string) |
118
- | preview | instruction3 | instruction on preview screen | ""(empty string) |
119
- | preview | backgroundColor | background color of preview screen | null |
120
- | instruction <sup>**New**</sup> | title | Instruction's title on camera caputre screen | ""(empty string) |
121
- | instruction <sup>**New**</sup> | refImage1 | Instruction's reference image 1 | null |
122
- | instruction <sup>**New**</sup> | refImage2 | Instruction's reference image 2 | null |
123
- | - | showPreviewInstruction | Show or hide preview instruction for captured photos | false |
109
+ | - | Property name | Description | Default value |
110
+ | ------------------------------ | ------------------------------ | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
111
+ | - | torchBtnEnabled | to show torch button. If set to true, it will only be shown if onFlash from captureConfig is set to false. | false |
112
+ | - | crop | crop the frame area | false |
113
+ | - | width | width to resize the image | original width |
114
+ | - | imageQuality | quality of image | 1.0 (range from 0.0 to 1.0) |
115
+ | frame | size | size of the frame (width and height) | 90% of screen width and height is scaled proportionally according to card ratio |
116
+ | frame | color | color of the frame | #ffffff |
117
+ | frame | content | content of the frame (able to display svg file within the frame for guidance | null |
118
+ | - | showOverlay | transparent black overlay | true |
119
+ | topLabel | text | text of the top label | ""(empty string) |
120
+ | topLabel | color | color of the top label | #ffffff |
121
+ | topLabel | size | text size of the top label | 20 |
122
+ | bottomLabel | text | text of the bottom label | ""(empty string) |
123
+ | bottomLabel | color | color of the bottom label | #ffffff |
124
+ | bottomLabel | size | text size of the bottom label | 20 |
125
+ | timer | backgroundColor | background of the count down timer | #ffa500 |
126
+ | timer | textColor | text color of the count down timer | #ffffff |
127
+ | confirmBtnConfig | backgroundColor | background color of the confirm button | #ffa500 |
128
+ | confirmBtnConfig | contentColor | content color of the confirm button | #ffffff |
129
+ | retakeBtnConfig | backgroundColor | background color of the retake button | #ffa500 |
130
+ | retakeBtnConfig | contentColor | content color of the retake button | #ffffff |
131
+ | - | captureBtnColor | color of the capture button | #ffffff |
132
+ | - | firstPhotoConfig | config for the first capture | delay:0s,onFlash:false,outputPath: null |
133
+ | - | secondPhotoConfig | config for the second capture | null |
134
+ | preview | title | title on preview screen | ""(empty string) |
135
+ | preview | refImg | ref image on preview screen | null |
136
+ | preview | instruction1 | instruction on preview screen | ""(empty string) |
137
+ | preview | instruction2 | instruction on preview screen | ""(empty string) |
138
+ | preview | instruction3 | instruction on preview screen | ""(empty string) |
139
+ | preview | backgroundColor | background color of preview screen | null |
140
+ | instruction <sup>**New**</sup> | title | Instruction's title on camera caputre screen | ""(empty string) |
141
+ | instruction <sup>**New**</sup> | refImage1 | Instruction's reference image 1 | null |
142
+ | instruction <sup>**New**</sup> | refImage2 | Instruction's reference image 2 | null |
143
+ | - | showPreviewInstruction | Show or hide preview instruction for captured photos | false |
144
+ | - | autoCapture <sup>**New**</sup> | Boolean to auto capture document | false |
124
145
 
125
146
  ## Usage
126
147
 
@@ -196,6 +217,7 @@ captureDocument(
196
217
  },
197
218
  },
198
219
  showPreviewInstruction: false,
220
+ autoCapture: true
199
221
  }
200
222
  )
201
223
  .then(result => {
@@ -21,10 +21,11 @@ android {
21
21
  compileSdkVersion 34
22
22
 
23
23
  defaultConfig {
24
- minSdkVersion 21
24
+ minSdkVersion 30
25
25
  targetSdkVersion 34
26
26
  versionCode 1
27
27
  versionName "1.0"
28
+ consumerProguardFiles("consumer-rules.pro")
28
29
  }
29
30
  lintOptions {
30
31
  abortOnError false
@@ -43,7 +44,7 @@ repositories {
43
44
 
44
45
  dependencies {
45
46
  implementation "com.facebook.react:react-android"
46
- implementation('com.innov8tif.okaycam:OkayCam:2.0.8@aar') {
47
+ implementation('com.innov8tif.okaycam:OkayCam:3.0.1@aar') {
47
48
  transitive = true
48
49
  exclude group: "junit", module: "junit"
49
50
  exclude group: "org.hamcrest", module: "hamcrest-core"
@@ -51,4 +52,4 @@ dependencies {
51
52
  implementation 'com.googlecode.json-simple:json-simple:1.1.1'
52
53
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
53
54
  implementation 'com.caverock:androidsvg-aar:1.4'
54
- }
55
+ }
@@ -0,0 +1,132 @@
1
+ # This is a configuration file for ProGuard.
2
+ # http://proguard.sourceforge.net/index.html#manual/usage.html
3
+ #
4
+ # Starting with version 2.2 of the Android plugin for Gradle, this file is distributed together with
5
+ # the plugin and unpacked at build-time. The files in $ANDROID_HOME are no longer maintained and
6
+ # will be ignored by new version of the Android plugin for Gradle.
7
+
8
+ # Optimizations: If you don't want to optimize, use the proguard-android.txt configuration file
9
+ # instead of this one, which turns off the optimization flags.
10
+ # Adding optimization introduces certain risks, since for example not all optimizations performed by
11
+ # ProGuard works on all versions of Dalvik. The following flags turn off various optimizations
12
+ # known to have issues, but the list may not be complete or up to date. (The "arithmetic"
13
+ # optimization can be used if you are only targeting Android 2.0 or later.) Make sure you test
14
+ # thoroughly if you go this route.
15
+ -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
16
+ -optimizationpasses 5
17
+
18
+ -dontusemixedcaseclassnames
19
+ -dontskipnonpubliclibraryclasses
20
+ -verbose
21
+
22
+ # Preserve some attributes that may be required for reflection.
23
+ -keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod
24
+
25
+ -keep public class com.google.vending.licensing.ILicensingService
26
+ -keep public class com.android.vending.licensing.ILicensingService
27
+ -keep public class com.google.android.vending.licensing.ILicensingService
28
+ -dontnote com.android.vending.licensing.ILicensingService
29
+ -dontnote com.google.vending.licensing.ILicensingService
30
+ -dontnote com.google.android.vending.licensing.ILicensingService
31
+
32
+ # For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
33
+ -keepclasseswithmembernames,includedescriptorclasses class * {
34
+ native <methods>;
35
+ }
36
+
37
+ # Keep setters in Views so that animations can still work.
38
+ -keepclassmembers public class * extends android.view.View {
39
+ void set*(***);
40
+ *** get*();
41
+ }
42
+
43
+ # We want to keep methods in Activity that could be used in the XML attribute onClick.
44
+ -keepclassmembers class * extends android.app.Activity {
45
+ public void *(android.view.View);
46
+ }
47
+
48
+ # For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
49
+ -keepclassmembers enum * {
50
+ public static **[] values();
51
+ public static ** valueOf(java.lang.String);
52
+ }
53
+
54
+ -keepclassmembers class * implements android.os.Parcelable {
55
+ public static final ** CREATOR;
56
+ }
57
+
58
+ # Preserve annotated Javascript interface methods.
59
+ -keepclassmembers class * {
60
+ @android.webkit.JavascriptInterface <methods>;
61
+ }
62
+
63
+ # The support libraries contains references to newer platform versions.
64
+ # Don't warn about those in case this app is linking against an older
65
+ # platform version. We know about them, and they are safe.
66
+ -dontnote android.support.**
67
+ -dontnote androidx.**
68
+ -dontwarn android.support.**
69
+ -dontwarn androidx.**
70
+
71
+ # This class is deprecated, but remains for backward compatibility.
72
+ -dontwarn android.util.FloatMath
73
+
74
+ # Understand the @Keep support annotation.
75
+ -keep class android.support.annotation.Keep
76
+ -keep class androidx.annotation.Keep
77
+
78
+ -keep @android.support.annotation.Keep class * {*;}
79
+ -keep @androidx.annotation.Keep class * {*;}
80
+
81
+ -keepclasseswithmembers class * {
82
+ @android.support.annotation.Keep <methods>;
83
+ }
84
+
85
+ -keepclasseswithmembers class * {
86
+ @androidx.annotation.Keep <methods>;
87
+ }
88
+
89
+ -keepclasseswithmembers class * {
90
+ @android.support.annotation.Keep <fields>;
91
+ }
92
+
93
+ -keepclasseswithmembers class * {
94
+ @androidx.annotation.Keep <fields>;
95
+ }
96
+
97
+ -keepclasseswithmembers class * {
98
+ @android.support.annotation.Keep <init>(...);
99
+ }
100
+
101
+ -keepclasseswithmembers class * {
102
+ @androidx.annotation.Keep <init>(...);
103
+ }
104
+
105
+ -keep class h5.** { *; }
106
+ -keep class p5.** { *; }
107
+ -keep class k5.** { *; }
108
+ -keep class n5.** { *; }
109
+ -keep class c6.** { *; }
110
+ -keep class x5.** { *; }
111
+
112
+ -keepnames class h5.**
113
+ -keepclassmembers class h5.** {
114
+ *;
115
+ }
116
+
117
+ -keep class com.google.mediapipe.proto.** { *; }
118
+ -keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite { *; }
119
+ -keep class com.google.common.flogger.** { *; }
120
+
121
+ # These classes are duplicated between android.jar and org.apache.http.legacy.jar.
122
+ -dontnote org.apache.http.**
123
+ -dontnote android.net.http.**
124
+
125
+ # These classes are duplicated between android.jar and core-lambda-stubs.jar.
126
+ -dontnote java.lang.invoke.**
127
+
128
+ # Don't warn about missing compile-only javax.lang.model.* classes
129
+ -dontwarn javax.lang.model.**
130
+ -dontwarn com.google.errorprone.annotations.CanIgnoreReturnValue
131
+ -dontwarn com.google.errorprone.annotations.CheckReturnValue
132
+ -dontwarn com.google.errorprone.annotations.MustBeClosed
@@ -1,6 +1,6 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
6
 
@@ -140,6 +140,7 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
140
140
 
141
141
  okayCamConfig.setPreview(getPreviewConfig(preview, frameConfig));
142
142
  okayCamConfig.setInstruction(getInstructionConfig(instruction, frameConfig));
143
+ okayCamConfig.setAutoCapture(userConfig.getBoolean("autoCapture"));
143
144
 
144
145
  OkayCamDoc.start(this.getCurrentActivity(), LICENSE_KEY, okayCamConfig, (success, images, exception) -> {
145
146
 
package/index.ts CHANGED
@@ -61,7 +61,6 @@ interface CaptureConfig {
61
61
  delay: number;
62
62
  onFlash: Boolean;
63
63
  outputPath?: string;
64
- onImageQuality: Boolean;
65
64
  }
66
65
 
67
66
  interface SwitchBtnConfig {
@@ -76,13 +75,6 @@ const defaultColor = "#ffffff";
76
75
  const defaultColor2 = "#ffa500";
77
76
  const imageResizedWidth = -1;
78
77
 
79
- const imageResolvedAssetSource: ImageResolvedAssetSource = {
80
- height: 0,
81
- width: 0,
82
- scale: 0,
83
- uri: "",
84
- };
85
-
86
78
  const labelConfig: LabelConfig = {
87
79
  text: "",
88
80
  color: defaultColor,
@@ -95,7 +87,7 @@ const defaultFrame: Frame = {
95
87
  height: (screenWidth * 54) / 85,
96
88
  },
97
89
  color: defaultColor,
98
- content: imageResolvedAssetSource,
90
+ content: null,
99
91
  };
100
92
 
101
93
  const timerConfig: TimerConfig = {
@@ -113,37 +105,31 @@ const defaultCaptureBtnColor: string = defaultColor;
113
105
  const captureConfigFirst: CaptureConfig = {
114
106
  delay: 0,
115
107
  onFlash: false,
116
- outputPath: "",
117
- onImageQuality: false,
108
+ outputPath: null,
118
109
  };
119
110
 
120
- const defaultPreview: OkayCamPreviewConfig = null!;
111
+ const defaultPreview: OkayCamPreviewConfig = null;
121
112
 
122
- const defaultInstruction: OkayCamInstruction = null!;
113
+ const defaultInstruction: OkayCamInstruction = null;
123
114
 
124
- const captureConfigSecond: CaptureConfig = {
125
- delay: 5,
126
- onFlash: false,
127
- outputPath: "",
128
- onImageQuality: false,
129
- };
115
+ const captureConfigSecond: CaptureConfig = null;
130
116
 
131
117
  const formatImage = (img: ImageResolvedAssetSource) => {
132
- // return Image.resolveAssetSource(img).uri;
133
- return img;
118
+ return Image.resolveAssetSource(img).uri;
119
+ // return img;
134
120
  };
135
121
 
136
122
  const formatInstruction = (
137
123
  instruction: OkayCamInstruction
138
124
  ): OkayCamInstruction => {
139
- if (instruction == null) return null!;
125
+ if (instruction == null) return null;
140
126
 
141
127
  const ref1: OkaycamInstructionRefImg = {
142
128
  ...instruction.refImage1,
143
129
  img: formatImage(instruction.refImage1.img),
144
130
  };
145
131
 
146
- let ref2: OkaycamInstructionRefImg = null!;
132
+ let ref2: OkaycamInstructionRefImg = null;
147
133
  if (instruction.refImage2 != null) {
148
134
  ref2 = {
149
135
  ...instruction.refImage2,
@@ -181,100 +167,13 @@ export const captureDocument = (
181
167
  preview = defaultPreview,
182
168
  instruction = defaultInstruction,
183
169
  showPreviewInstruction = false,
170
+ autoCapture = true,
184
171
  }
185
172
  ) => {
186
- if (topLabel.text == undefined) {
187
- topLabel.text = labelConfig.text;
188
- }
189
-
190
- if (topLabel.color == undefined) {
191
- topLabel.color = labelConfig.color;
192
- }
193
-
194
- if (topLabel.size == undefined) {
195
- topLabel.size = labelConfig.size;
196
- }
197
-
198
- if (bottomLabel.text == undefined) {
199
- bottomLabel.text = labelConfig.text;
200
- }
201
-
202
- if (bottomLabel.color == undefined) {
203
- bottomLabel.color = labelConfig.color;
204
- }
205
-
206
- if (bottomLabel.size == undefined) {
207
- bottomLabel.size = labelConfig.size;
208
- }
209
-
210
173
  if (frame.size == undefined) {
211
174
  frame.size = defaultFrame.size;
212
175
  }
213
176
 
214
- if (timer.backgroundColor == undefined || timer.textColor == undefined) {
215
- timer.backgroundColor = timerConfig.backgroundColor;
216
- }
217
-
218
- if (timer.textColor == undefined) {
219
- timer.textColor = timerConfig.textColor;
220
- }
221
-
222
- if (confirmBtnConfig.backgroundColor == undefined) {
223
- confirmBtnConfig.backgroundColor = okayCamBtnConfig.backgroundColor;
224
- }
225
-
226
- if (confirmBtnConfig.contentColor == undefined) {
227
- confirmBtnConfig.contentColor = okayCamBtnConfig.contentColor;
228
- }
229
-
230
- if (retakeBtnConfig.backgroundColor == undefined) {
231
- retakeBtnConfig.backgroundColor = okayCamBtnConfig.backgroundColor;
232
- }
233
-
234
- if (retakeBtnConfig.contentColor == undefined) {
235
- retakeBtnConfig.contentColor = okayCamBtnConfig.contentColor;
236
- }
237
-
238
- if (captureBtnColor == undefined) {
239
- captureBtnColor = defaultCaptureBtnColor;
240
- }
241
-
242
- if (firstPhotoConfig.delay == undefined) {
243
- firstPhotoConfig.delay = captureConfigFirst.delay;
244
- }
245
-
246
- if (firstPhotoConfig.onFlash == undefined) {
247
- firstPhotoConfig.onFlash = captureConfigFirst.onFlash;
248
- }
249
-
250
- if (firstPhotoConfig.onImageQuality == undefined) {
251
- firstPhotoConfig.onImageQuality = captureConfigFirst.onImageQuality;
252
- }
253
-
254
- if (firstPhotoConfig.outputPath == undefined) {
255
- firstPhotoConfig.outputPath = captureConfigFirst.outputPath;
256
- }
257
-
258
- if (secondPhotoConfig.delay == undefined) {
259
- secondPhotoConfig.delay = captureConfigSecond.delay;
260
- }
261
-
262
- if (secondPhotoConfig.onFlash == undefined) {
263
- secondPhotoConfig.onFlash = captureConfigSecond.onFlash;
264
- }
265
-
266
- if (secondPhotoConfig.onImageQuality == undefined) {
267
- secondPhotoConfig.onImageQuality = captureConfigSecond.onImageQuality;
268
- }
269
-
270
- if (secondPhotoConfig.outputPath == undefined) {
271
- secondPhotoConfig.outputPath = captureConfigSecond.outputPath;
272
- }
273
-
274
- if (width == undefined) {
275
- width = imageResizedWidth;
276
- }
277
-
278
177
  const resultedPreview =
279
178
  preview == null
280
179
  ? null
@@ -323,6 +222,7 @@ export const captureDocument = (
323
222
  preview: resultedPreview,
324
223
  instruction: formatInstruction(instruction),
325
224
  showPreviewInstruction: showPreviewInstruction,
225
+ autoCapture: autoCapture,
326
226
  },
327
227
  })
328
228
  .then((result) => {
@@ -357,54 +257,6 @@ export const captureSelfie = (
357
257
  imageQuality = 1.0,
358
258
  }
359
259
  ) => {
360
- if (topLabel.text == undefined) {
361
- topLabel.text = labelConfig.text;
362
- }
363
-
364
- if (topLabel.color == undefined) {
365
- topLabel.color = labelConfig.color;
366
- }
367
-
368
- if (topLabel.size == undefined) {
369
- topLabel.size = labelConfig.size;
370
- }
371
-
372
- if (switchBtnConfig.color == undefined) {
373
- switchBtnConfig.color = defaultSwitchBtnConfig.color;
374
- }
375
-
376
- if (switchBtnConfig.show == undefined) {
377
- switchBtnConfig.show = defaultSwitchBtnConfig.show;
378
- }
379
-
380
- if (confirmBtnConfig.backgroundColor == undefined) {
381
- confirmBtnConfig.backgroundColor = okayCamBtnConfig.backgroundColor;
382
- }
383
-
384
- if (confirmBtnConfig.contentColor == undefined) {
385
- confirmBtnConfig.contentColor = okayCamBtnConfig.contentColor;
386
- }
387
-
388
- if (retakeBtnConfig.backgroundColor == undefined) {
389
- retakeBtnConfig.backgroundColor = okayCamBtnConfig.backgroundColor;
390
- }
391
-
392
- if (retakeBtnConfig.contentColor == undefined) {
393
- retakeBtnConfig.contentColor = okayCamBtnConfig.contentColor;
394
- }
395
-
396
- if (defaultCameraFacing == undefined) {
397
- defaultCameraFacing = cameraFacing;
398
- }
399
-
400
- if (captureBtnColor == undefined) {
401
- captureBtnColor = defaultCaptureBtnColor;
402
- }
403
-
404
- if (width == undefined) {
405
- width = imageResizedWidth;
406
- }
407
-
408
260
  return new Promise(function (resolve, reject) {
409
261
  RNOkayCam.captureSelfie({
410
262
  license: license,
@@ -44,6 +44,7 @@ class RNOkayCam: NSObject {
44
44
  let torchBtnEnabled = rnOkayCamConfig.object(forKey: "torchBtnEnabled") as! Bool
45
45
  let width = rnOkayCamConfig.object(forKey: "width") as! Int
46
46
  let imageQuality = rnOkayCamConfig.object(forKey: "imageQuality") as! CGFloat
47
+ let autoCapture = rnOkayCamConfig.object(forKey: "autoCapture") as! Bool
47
48
 
48
49
  DispatchQueue.main.async {
49
50
  let rootViewController = (UIApplication.shared.keyWindow?.rootViewController)!
@@ -107,13 +108,11 @@ class RNOkayCam: NSObject {
107
108
  firstPhoto: OkayCamCaptureConfig(
108
109
  timeOut: firstPhoto.object(forKey: "delay") as! Int,
109
110
  onFlash: firstPhoto.object(forKey: "onFlash") as! Bool,
110
- onImageQuality: firstPhoto.object(forKey: "onImageQuality") as! Bool,
111
- outputPath: (firstPhotoPath != nil) ? URL(string: (firstPhoto.object(forKey: "outputPath") as? String)!) : nil
111
+ outputPath: (firstPhotoPath != nil) ? URL(string: (firstPhoto.object(forKey: "outputPath") as? String)!) : nil
112
112
  ),
113
113
  secondPhoto: (secondPhoto != nil) ? OkayCamCaptureConfig(
114
114
  timeOut: secondPhoto?.object(forKey: "delay") as? Int ?? 0,
115
115
  onFlash: secondPhoto?.object(forKey: "onFlash") as? Bool ?? false,
116
- onImageQuality: secondPhoto?.object(forKey: "onImageQuality") as! Bool,
117
116
  outputPath: (secondPhotoPath != nil) ? URL(string: (secondPhoto?.object(forKey: "outputPath") as! String?)!) : nil
118
117
  ) : nil
119
118
  )
@@ -134,6 +133,8 @@ class RNOkayCam: NSObject {
134
133
  let instructionConfig = rnOkayCamConfig.object(forKey: "instruction") as? NSDictionary
135
134
  okayCamConfig.instruction = self.getOkayCamInstruction(instructionConfig: instructionConfig)
136
135
 
136
+ okayCamConfig.autoCapture = autoCapture
137
+
137
138
  // start the SDK
138
139
  OkayCamDoc.start(
139
140
  okayCamConfig: okayCamConfig,
@@ -398,7 +399,12 @@ class RNOkayCam: NSObject {
398
399
  case .cameraPermission:
399
400
  reject("camera permission denied", "camera permission denied", nil)
400
401
  return
402
+ case .failedToCreateIADBundle:
403
+ reject("failed to create IAD bundle", "failed to create IAD bundle", nil)
404
+ return
405
+ @unknown default:
406
+ reject("no error", "no error", nil)
407
+ return
401
408
  }
402
409
  }
403
410
  }
404
-
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-okaycam",
3
3
  "title": "React Native OkayCam",
4
- "version": "2.0.5",
4
+ "version": "3.0.1",
5
5
  "description": "React-Native version of OkayCam",
6
6
  "main": "index.ts",
7
7
  "files": [
@@ -9,22 +9,26 @@
9
9
  "android",
10
10
  "index.ts",
11
11
  "ios",
12
+ "setup_podfile.js",
12
13
  "react-native-okaycam.podspec"
13
14
  ],
14
15
  "scripts": {
15
- "test": "echo \"Error: no test specified\" && exit 1"
16
+ "test": "echo \"Error: no test specified\" && exit 1",
17
+ "postinstall": "node setup_podfile.js"
16
18
  },
17
19
  "repository": {
18
20
  "type": "git",
19
- "url": "git+https://gitlab.com/innov8tif-ekyc-product/okaycam/mobile/react-native-okaycam.git",
20
- "baseUrl": "https://gitlab.com/innov8tif-ekyc-product/okaycam/mobile/react-native-okaycam.git"
21
+ "url": "git+https://gitlab.com/innov8tif-ekyc-product/okaycam/mobile/react-native-okaycam.git"
21
22
  },
22
23
  "keywords": [
23
- "react-native"
24
+ "react-native",
25
+ "camera",
26
+ "okaycam",
27
+ "ios-sdk"
24
28
  ],
25
29
  "author": {
26
- "name": "Raymond",
27
- "email": "raymond@innov8tif.com"
30
+ "name": "innov8tif",
31
+ "email": "ekyc.team@innov8tif.com"
28
32
  },
29
33
  "license": "MIT",
30
34
  "licenseFilename": "LICENSE",
@@ -33,8 +37,12 @@
33
37
  "react": "^18.0.2",
34
38
  "react-native": ">=0.75.2 <1.0.x"
35
39
  },
40
+ "dependencies": {
41
+ "fs-extra": "^11.2.0"
42
+ },
36
43
  "devDependencies": {
37
- "react": "^18.0.2",
38
- "react-native": "^0.75.2"
44
+ "typescript": "^5.4.0",
45
+ "@types/node": "^20.10.0",
46
+ "@react-native/cli": "^13.2.0"
39
47
  }
40
48
  }
@@ -6,24 +6,32 @@ Pod::Spec.new do |s|
6
6
  s.name = "react-native-okaycam"
7
7
  s.version = package["version"]
8
8
  s.summary = package["description"]
9
- s.description = <<-DESC
10
- react-native-okaycam
11
- DESC
9
+ s.description = "React Native bridge for OkayCam iOS SDK"
12
10
  s.homepage = "https://gitlab.com/innov8tif-ekyc-product/okaycam/mobile/react-native-okaycam.git"
13
- # brief license entry:
14
11
  s.license = "MIT"
15
- # optional - use expanded license entry instead:
16
- # s.license = { :type => "MIT", :file => "LICENSE" }
17
- s.authors = { "Raymond Lau" => "raymond@innov8tif.com" }
18
- s.platforms = { :ios => "9.0" }
12
+ s.authors = { "Innov8tif" => "ekyc.team@innov8tif.com" }
13
+ s.platforms = { :ios => "15.0" }
19
14
  s.source = { :git => "https://gitlab.com/innov8tif-ekyc-product/okaycam/mobile/react-native-okaycam.git", :tag => "#{s.version}" }
20
15
 
21
- s.source_files = "ios/**/*.{h,c,m,swift}"
16
+ s.source_files = "ios/**/*.{h,m,swift}"
22
17
  s.requires_arc = true
23
18
  s.static_framework = true
24
- s.dependency "React"
25
- s.dependency "OkayCam", "2.0.18"
26
- end
19
+ s.swift_version = "5.0"
20
+ s.module_name = "ReactNativeOkayCamV3"
21
+
22
+ # React Native dependencies
23
+ s.dependency "React-Core"
24
+ s.dependency "ReactCommon/turbomodule/core"
25
+ s.dependency "React-RCTAppDelegate"
26
+ s.dependency "React-RCTFabric"
27
27
 
28
+ # OkayCam CocoaPod dependency
29
+ s.dependency "OkayCam", "3.0.5"
30
+ s.dependency "CryptoSwift", "1.8.2"
28
31
 
29
-
32
+ s.pod_target_xcconfig = {
33
+ 'DEFINES_MODULE' => 'YES',
34
+ 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64',
35
+ 'LD_RUNPATH_SEARCH_PATHS' => '$(inherited) @executable_path/Frameworks @loader_path/Frameworks'
36
+ }
37
+ end
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync, readFileSync, writeFileSync } from "fs";
3
+ import { join, resolve } from "path";
4
+
5
+ import { fileURLToPath } from "url";
6
+ import { dirname } from "path";
7
+
8
+ console.log("đŸĒĒ OkayCam setup script running...");
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = dirname(__filename);
12
+
13
+ // --- Find project root ---
14
+ let currentDir = __dirname;
15
+ let projectRoot = null;
16
+
17
+ for (let i = 0; i < 6; i++) {
18
+ const iosPath = join(currentDir, "ios", "Podfile");
19
+ if (existsSync(iosPath)) {
20
+ projectRoot = currentDir;
21
+ break;
22
+ }
23
+ currentDir = resolve(currentDir, "..");
24
+ }
25
+
26
+ if (!projectRoot) {
27
+ console.warn("đŸšĢ Could not find ios/Podfile — skipping OkayCam setup.");
28
+ process.exit(0);
29
+ }
30
+
31
+ const podfilePath = join(projectRoot, "ios", "Podfile");
32
+ console.log(`📄 Found Podfile at: ${podfilePath}`);
33
+
34
+ let podfile = readFileSync(podfilePath, "utf8");
35
+
36
+ // --- Check if already added ---
37
+ if (podfile.includes("đŸĒĒ Re-sign OkayCam Frameworks")) {
38
+ console.log("â„šī¸ OkayCam post_install hook already exists — skipping.");
39
+ process.exit(0);
40
+ }
41
+
42
+ // --- The Ruby hook to inject ---
43
+ const hook = `
44
+ post_install do |installer|
45
+ installer.aggregate_targets.each do |target|
46
+ target.user_project.native_targets.each do |native_target|
47
+ phase_name = "Re-sign OkayCam Frameworks"
48
+ next if native_target.shell_script_build_phases.any? { |p| p.name == phase_name }
49
+
50
+ script = <<~SCRIPT
51
+ echo "Re-signing embedded frameworks..."
52
+ set -e
53
+ APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
54
+ find "$APP_PATH/Frameworks" -type d -name "*.framework" | while read framework
55
+ do
56
+ echo "Re-signing $framework"
57
+ /usr/bin/codesign --force --sign "$EXPANDED_CODE_SIGN_IDENTITY" --deep --preserve-metadata=identifier,entitlements "$framework"
58
+ done
59
+ SCRIPT
60
+
61
+ phase = native_target.new_shell_script_build_phase(phase_name)
62
+ phase.shell_script = script
63
+ end
64
+ end
65
+ end
66
+ `;
67
+
68
+ if (podfile.includes("post_install do |installer|")) {
69
+ console.log(
70
+ "🔧 Detected existing post_install block — injecting after react_native_post_install"
71
+ );
72
+
73
+ const innerHook = `
74
+ # Re-sign OkayCam Frameworks
75
+ installer.aggregate_targets.each do |target|
76
+ target.user_project.native_targets.each do |native_target|
77
+ phase_name = "Re-sign OkayCam Frameworks"
78
+ next if native_target.shell_script_build_phases.any? { |p| p.name == phase_name }
79
+
80
+ script = <<~SCRIPT
81
+ echo "Re-signing embedded frameworks..."
82
+ set -e
83
+ APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
84
+ find "$APP_PATH/Frameworks" -type d -name "*.framework" | while read framework
85
+ do
86
+ echo "Re-signing $framework"
87
+ /usr/bin/codesign --force --sign "$EXPANDED_CODE_SIGN_IDENTITY" --deep --preserve-metadata=identifier,entitlements "$framework"
88
+ done
89
+ SCRIPT
90
+
91
+ phase = native_target.new_shell_script_build_phase(phase_name)
92
+ phase.shell_script = script
93
+ end
94
+ end
95
+ `;
96
+
97
+ if (podfile.includes("react_native_post_install")) {
98
+ podfile = podfile.replace(
99
+ /(react_native_post_install\s*\(.*\)\s*)/,
100
+ `$1\n${innerHook}`
101
+ );
102
+ console.log("✨ Injected OkayCam hook after react_native_post_install.");
103
+ } else {
104
+ console.log(
105
+ "âš ī¸ react_native_post_install not found, appending before end of post_install."
106
+ );
107
+ podfile = podfile.replace(/end\s*$/, `${innerHook}\nend`);
108
+ }
109
+ } else {
110
+ console.log("✨ No post_install found — creating a new one.");
111
+ podfile += `
112
+ ${hook}
113
+ `;
114
+ }
115
+
116
+ writeFileSync(podfilePath, podfile, "utf8");
117
+ console.log("✅ Successfully added OkayCam re-sign hook.");