react-native-rectangle-doc-scanner 3.180.0 → 3.181.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.180.0",
3
+ "version": "3.181.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -109,6 +109,14 @@ static inline void dispatch_async_main_queue(dispatch_block_t block)
109
109
  - (void)_foregroundMode
110
110
  {
111
111
  self.forceStop = NO;
112
+
113
+ // If the session was stopped while the app was backgrounded, bring it back
114
+ if (self.captureSession && !self.captureSession.isRunning) {
115
+ NSLog(@"[IPDFCameraViewController] Foreground - restarting capture session");
116
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
117
+ [self.captureSession startRunning];
118
+ });
119
+ }
112
120
  }
113
121
 
114
122
  - (void)dealloc
@@ -204,6 +212,17 @@ static inline void dispatch_async_main_queue(dispatch_block_t block)
204
212
  AVCaptureConnection *connection = [dataOutput.connections firstObject];
205
213
  [connection setVideoOrientation:AVCaptureVideoOrientationPortrait];
206
214
 
215
+ // Restart capture session automatically after media services/interruption events
216
+ [[NSNotificationCenter defaultCenter] addObserver:self
217
+ selector:@selector(handleSessionRuntimeError:)
218
+ name:AVCaptureSessionRuntimeErrorNotification
219
+ object:session];
220
+
221
+ [[NSNotificationCenter defaultCenter] addObserver:self
222
+ selector:@selector(handleSessionInterruptionEnded:)
223
+ name:AVCaptureSessionInterruptionEndedNotification
224
+ object:session];
225
+
207
226
  if (device.isFlashAvailable)
208
227
  {
209
228
  [device lockForConfiguration:nil];
@@ -221,6 +240,34 @@ static inline void dispatch_async_main_queue(dispatch_block_t block)
221
240
  [session commitConfiguration];
222
241
  }
223
242
 
243
+ - (void)handleSessionRuntimeError:(NSNotification *)notification
244
+ {
245
+ NSError *error = notification.userInfo[AVCaptureSessionErrorKey];
246
+ NSLog(@"[IPDFCameraViewController] Session runtime error: %@", error);
247
+
248
+ // Common case: AVErrorMediaServicesWereReset requires restarting the session
249
+ if (error.code == AVErrorMediaServicesWereReset) {
250
+ [self restartCaptureSession:@"Media services were reset"];
251
+ }
252
+ }
253
+
254
+ - (void)handleSessionInterruptionEnded:(NSNotification *)notification
255
+ {
256
+ [self restartCaptureSession:@"Interruption ended"];
257
+ }
258
+
259
+ - (void)restartCaptureSession:(NSString *)reason
260
+ {
261
+ if (!self.captureSession || self.captureSession.isRunning) {
262
+ return;
263
+ }
264
+
265
+ NSLog(@"[IPDFCameraViewController] Restarting capture session (%@)", reason);
266
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
267
+ [self.captureSession startRunning];
268
+ });
269
+ }
270
+
224
271
  - (void)setCameraViewType:(IPDFCameraViewType)cameraViewType
225
272
  {
226
273
  UIBlurEffect * effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];