Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: [IOBP-972] Vision camera functionality has been restricted by th…
…e operating system (#6410) ## Short description This pull request includes changes to the `BarcodeScanBaseScreenComponent` to address an issue where a black screen appears when the app is not in an active state. ## List of changes proposed in this pull request - Implemented a `useEffect` to update the app state and background status when the app state changes - Updated the `isDisabled` property to also check if the app is in the background, ensuring the barcode scanner is disabled when the app is not active ## How to test‼️ **Use a physical device**‼️ To test the old behavior omit the `isAppInBackground` flag. - Add some logs to the `BarcodeScanBaseScreenComponent.tsx` file: ``` React.useEffect(() => { const subscription = AppState.addEventListener("change", nextAppState => { if ( appState.current.match(/inactive|background/) && nextAppState === "active" ) { console.log("App has come to the foreground!"); } // eslint-disable-next-line functional/immutable-data appState.current = nextAppState; setIsAppInBackground(appState.current !== "active"); console.log("AppState", appState.current); }); return () => { subscription.remove(); }; }, []); ``` - Tap on `Inquadra` - Switch to the device's `Camera` application without closing the `io-app`. Observe if an error is logged while switching. - Minimize the `io-app` and return to the device's home screen without closing the app. Wait for approximately one/two minutes and check if any errors are logged during this time. - Reopen the `io-app` from the background and verify that the scanner screen do not appears black and works as expected. ## Preview | Without `isAppInBackground` | With `isAppInBackground` | |--------|--------| | <img width="902" alt="Screenshot 2024-11-15 at 17 26 27" src="https://github.com/user-attachments/assets/2210ca95-64ad-4bb6-ae04-38aecf37f54f"> | <img width="902" alt="Screenshot 2024-11-15 at 17 30 17" src="https://github.com/user-attachments/assets/a819c230-597c-47df-96a8-97368a2ac7aa">| Co-authored-by: Alessandro <[email protected]>
- Loading branch information