react-native-rectangle-doc-scanner 3.142.0 → 3.144.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.142.0",
3
+ "version": "3.144.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -52,8 +52,9 @@ class PdfScanner extends React.Component {
52
52
  return;
53
53
  }
54
54
  const { onPictureTaken, onProcessing } = this.props;
55
- DeviceEventEmitter.addListener('onPictureTaken', onPictureTaken);
56
- DeviceEventEmitter.addListener('onProcessingChange', onProcessing);
55
+ // React Native 0.76+ returns a subscription object from addListener
56
+ this.pictureListener = DeviceEventEmitter.addListener('onPictureTaken', onPictureTaken);
57
+ this.processingListener = DeviceEventEmitter.addListener('onProcessingChange', onProcessing);
57
58
  this.eventsSubscribed = true;
58
59
  }
59
60
 
@@ -61,9 +62,15 @@ class PdfScanner extends React.Component {
61
62
  if (Platform.OS !== 'android') {
62
63
  return;
63
64
  }
64
- const { onPictureTaken, onProcessing } = this.props;
65
- DeviceEventEmitter.removeListener('onPictureTaken', onPictureTaken);
66
- DeviceEventEmitter.removeListener('onProcessingChange', onProcessing);
65
+ // React Native 0.76+ uses removeAllListeners instead of removeListener
66
+ if (this.pictureListener) {
67
+ this.pictureListener.remove();
68
+ this.pictureListener = null;
69
+ }
70
+ if (this.processingListener) {
71
+ this.processingListener.remove();
72
+ this.processingListener = null;
73
+ }
67
74
  this.eventsSubscribed = false;
68
75
  }
69
76
 
@@ -73,10 +80,14 @@ class PdfScanner extends React.Component {
73
80
  }
74
81
  try {
75
82
  const granted = await PermissionsAndroid.requestMultiple([
83
+ PermissionsAndroid.PERMISSIONS.CAMERA,
76
84
  PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
77
85
  PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
78
86
  ]);
79
87
 
88
+ const cameraGranted =
89
+ granted['android.permission.CAMERA'] ===
90
+ PermissionsAndroid.RESULTS.GRANTED;
80
91
  const readGranted =
81
92
  granted['android.permission.READ_EXTERNAL_STORAGE'] ===
82
93
  PermissionsAndroid.RESULTS.GRANTED;
@@ -84,7 +95,7 @@ class PdfScanner extends React.Component {
84
95
  granted['android.permission.WRITE_EXTERNAL_STORAGE'] ===
85
96
  PermissionsAndroid.RESULTS.GRANTED;
86
97
 
87
- if (readGranted && writeGranted) {
98
+ if (cameraGranted && readGranted && writeGranted) {
88
99
  this.setState({ permissionsAuthorized: true });
89
100
  } else {
90
101
  this.onPermissionsDenied();