omnipay-reactnative-sdk 1.2.2-beta.6 → 1.2.2-beta.7

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.
@@ -110,7 +110,40 @@ public class OmnipayLivenessModule extends ReactContextBaseJavaModule {
110
110
  public void isSupported(Promise promise) {
111
111
  try {
112
112
  // Check if ML Kit face detection is available
113
- promise.resolve(true);
113
+ boolean hasMLKit = true;
114
+ try {
115
+ // Try to create ML Kit face detector to verify it's available
116
+ FaceDetectorOptions options = new FaceDetectorOptions.Builder()
117
+ .setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_FAST)
118
+ .setLandmarkMode(FaceDetectorOptions.LANDMARK_MODE_ALL)
119
+ .setClassificationMode(FaceDetectorOptions.CLASSIFICATION_MODE_ALL)
120
+ .build();
121
+ FaceDetection.getClient(options);
122
+ } catch (Exception e) {
123
+ Log.e(TAG, "ML Kit not available", e);
124
+ hasMLKit = false;
125
+ }
126
+
127
+ // Check if device has camera capability (independent of permission)
128
+ boolean hasCamera = false;
129
+ try {
130
+ android.content.Context context = getReactApplicationContext();
131
+ android.content.pm.PackageManager pm = context.getPackageManager();
132
+ hasCamera = pm.hasSystemFeature(android.content.pm.PackageManager.FEATURE_CAMERA_ANY) ||
133
+ pm.hasSystemFeature(android.content.pm.PackageManager.FEATURE_CAMERA_FRONT);
134
+ } catch (Exception e) {
135
+ Log.e(TAG, "Error checking camera features", e);
136
+ hasCamera = false;
137
+ }
138
+
139
+ boolean isSupported = hasMLKit && hasCamera;
140
+
141
+ Log.i(TAG, "Liveness Detection Support Check:");
142
+ Log.i(TAG, " ML Kit Available: " + hasMLKit);
143
+ Log.i(TAG, " Camera Available: " + hasCamera);
144
+ Log.i(TAG, " Overall Support: " + isSupported);
145
+
146
+ promise.resolve(isSupported);
114
147
  } catch (Exception e) {
115
148
  Log.e(TAG, "Error checking support", e);
116
149
  promise.resolve(false);
@@ -68,9 +68,29 @@ RCT_EXPORT_MODULE(OmnipayLivenessModule)
68
68
 
69
69
  RCT_EXPORT_METHOD(isSupported:(RCTPromiseResolveBlock)resolve
70
70
  rejecter:(RCTPromiseRejectBlock)reject) {
71
- // Check if Vision framework is available and camera is available
72
- BOOL isSupported = [VNDetectFaceRectanglesRequest class] != nil &&
73
- [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo] != nil;
71
+ // Check if Vision framework is available and device has camera capability
72
+ BOOL hasVisionFramework = [VNDetectFaceRectanglesRequest class] != nil;
73
+
74
+ // Check if device has camera (independent of permission status)
75
+ BOOL hasCamera = NO;
76
+ NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
77
+ hasCamera = devices.count > 0;
78
+
79
+ // Additional check for front camera specifically (for selfie mode)
80
+ if (!hasCamera) {
81
+ AVCaptureDevice *frontCamera = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInWideAngleCamera
82
+ mediaType:AVMediaTypeVideo
83
+ position:AVCaptureDevicePositionFront];
84
+ hasCamera = frontCamera != nil;
85
+ }
86
+
87
+ BOOL isSupported = hasVisionFramework && hasCamera;
88
+
89
+ RCTLogInfo(@"Liveness Detection Support Check:");
90
+ RCTLogInfo(@" Vision Framework: %@", hasVisionFramework ? @"YES" : @"NO");
91
+ RCTLogInfo(@" Camera Available: %@", hasCamera ? @"YES" : @"NO");
92
+ RCTLogInfo(@" Overall Support: %@", isSupported ? @"YES" : @"NO");
93
+
74
94
  resolve(@(isSupported));
75
95
  }
76
96
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnipay-reactnative-sdk",
3
- "version": "1.2.2-beta.6",
3
+ "version": "1.2.2-beta.7",
4
4
  "description": "Omnipay react native sdk",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",