@capgo/capacitor-document-scanner 8.3.3 → 8.3.5

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
@@ -11,6 +11,17 @@ Capacitor plugin to scan document iOS and Android
11
11
 
12
12
  The most complete doc is available here: https://capgo.app/docs/plugins/document-scanner/
13
13
 
14
+ ## Compatibility
15
+
16
+ | Plugin version | Capacitor compatibility | Maintained |
17
+ | -------------- | ----------------------- | ---------- |
18
+ | v8.\*.\* | v8.\*.\* | ✅ |
19
+ | v7.\*.\* | v7.\*.\* | On demand |
20
+ | v6.\*.\* | v6.\*.\* | ❌ |
21
+ | v5.\*.\* | v5.\*.\* | ❌ |
22
+
23
+ > **Note:** The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.
24
+
14
25
  ## Install
15
26
 
16
27
  ```bash
@@ -10,6 +10,7 @@ import android.graphics.ColorMatrix;
10
10
  import android.graphics.ColorMatrixColorFilter;
11
11
  import android.graphics.Paint;
12
12
  import android.net.Uri;
13
+ import android.os.Build;
13
14
  import android.util.Base64;
14
15
  import androidx.activity.result.ActivityResult;
15
16
  import androidx.activity.result.ActivityResultLauncher;
@@ -92,6 +93,16 @@ public class DocumentScannerPlugin extends Plugin {
92
93
  return;
93
94
  }
94
95
 
96
+ // Check if running on emulator
97
+ if (isRunningOnEmulator()) {
98
+ call.reject(
99
+ "Document scanner is not supported on Android emulators. " +
100
+ "The ML Kit Document Scanner requires a physical device with a hardware camera. " +
101
+ "Please test on a real Android device."
102
+ );
103
+ return;
104
+ }
105
+
95
106
  Activity activity = getActivity();
96
107
  if (activity == null) {
97
108
  call.reject("Activity reference is unavailable.");
@@ -393,6 +404,33 @@ public class DocumentScannerPlugin extends Plugin {
393
404
  }
394
405
  }
395
406
 
407
+ /**
408
+ * Detects if the app is running on an Android emulator.
409
+ * Uses multiple heuristics to reliably detect emulator environments.
410
+ * @return true if running on an emulator, false otherwise
411
+ */
412
+ private boolean isRunningOnEmulator() {
413
+ String model = Build.MODEL.toLowerCase(Locale.ROOT);
414
+ String product = Build.PRODUCT.toLowerCase(Locale.ROOT);
415
+ String fingerprint = Build.FINGERPRINT.toLowerCase(Locale.ROOT);
416
+ String manufacturer = Build.MANUFACTURER.toLowerCase(Locale.ROOT);
417
+ String brand = Build.BRAND.toLowerCase(Locale.ROOT);
418
+ String device = Build.DEVICE.toLowerCase(Locale.ROOT);
419
+
420
+ return (
421
+ fingerprint.startsWith("generic") ||
422
+ fingerprint.startsWith("unknown") ||
423
+ model.contains("google_sdk") ||
424
+ model.contains("emulator") ||
425
+ model.contains("android sdk built for x86") ||
426
+ manufacturer.contains("genymotion") ||
427
+ (brand.startsWith("generic") && device.startsWith("generic")) ||
428
+ "google_sdk".equals(product) ||
429
+ product.contains("sdk_gphone") ||
430
+ product.contains("emulator")
431
+ );
432
+ }
433
+
396
434
  @PluginMethod
397
435
  public void getPluginVersion(final PluginCall call) {
398
436
  try {
@@ -3,7 +3,7 @@ import Foundation
3
3
 
4
4
  @objc(DocumentScannerPlugin)
5
5
  public class DocumentScannerPlugin: CAPPlugin, CAPBridgedPlugin {
6
- private let pluginVersion: String = "8.3.3"
6
+ private let pluginVersion: String = "8.3.5"
7
7
  public let identifier = "DocumentScannerPlugin"
8
8
  public let jsName = "DocumentScanner"
9
9
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-document-scanner",
3
- "version": "8.3.3",
3
+ "version": "8.3.5",
4
4
  "description": "Capacitor plugin to scan document iOS and Android",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",