1

On IOS the first time a user who has not previously given permission for their camera the screen shows black screen. If the user closes the app and returns, the camera works fine.

A loading screen is shown before the permissions have been granted.

Can anyone help?

[black screen camera][1]

const __startCamera = async () => {
        setCameraState({
            ...cameraState,
            previewVisible: false,
            showConnectionError: false,
            showConfirmPage: false,
            showConfirmSuccess: false,
            capturedImage: undefined,
        });
        const { status } = await Camera.requestCameraPermissionsAsync();
        console.log(status);
        if (status === "granted") {
            console.log("granted", status);
            setCameraState({
                ...cameraState,
                isLoading: false,
            });
        } else {
            Alert.alert(t("camera.cameraPermissionError"));
            setCameraState({
                ...cameraState,
                isLoading: true,
            });
            navigation.navigate("Home");
        }


  [1]: https://i.stack.imgur.com/dl68S.png
  • Have you fixed this one? I faced this one too. Not sure if there is anything required to be handled. – sanjeev Oct 26 '21 at 10:00
  • No, unfortunately I was not able to fix this problem. I saw a suggestion to request Camera permission before navigating to the screen with the camera component. This bizarre behaviour only occurs on IOS and when accessing the camera for the first time. – stuartrapop Oct 26 '21 at 14:50
  • I kind of fixed it by using state while invoking barcode scanner. That way when the state is changed the barcode component refreshes and you'll have the scanner invoked. – sanjeev Oct 28 '21 at 01:57
  • That is what I thought I was doing by changing the isLoading state to false after confirming the granted status of the Camera permissions. This is hard to replicate, because the error only shows on real IOS devices on the first usage. There is no issue on android nor on the ios simulator. – stuartrapop Oct 29 '21 at 07:06

1 Answers1

0

Yo must check is your permission grandet and them render camera .

    import { Camera } from "expo-camera";
    
    const [permission, requestPermission] = Camera.useCameraPermissions();
    
     return ( 
    {permission?.granted ? (<Camera> </Camera>) : (<Text>Waiting you permsision"</Text>}
     );
Material
  • 49
  • 1
  • 9