Skip to content

🐛 Unable to request permission #3467

@DaveVaval

Description

@DaveVaval

What's happening?

I started a new project, and it is not the first time I use vision camera, but for some reason now I can't request permission. I even tried to manually call requestPermission() with a button and it automaticly returns false with nothing appearing on the screen.

Reproduceable Code

import { View, Text, StyleSheet, Button } from 'react-native'
import React, { useEffect } from 'react'
import { useCameraPermission, Camera, useCameraDevices, useCameraDevice } from 'react-native-vision-camera'

export default function Home() {
  const external = useCameraDevice('external');
  const back = useCameraDevice('back');
  const { hasPermission, requestPermission } = useCameraPermission();

  const request = async () => {
    const result = await requestPermission();
    console.log(result);
    // returns false immediatly after calling the function
  }
  
  if (!hasPermission) {
    console.log('no permission');
    request();
  }

  return (
    // <Camera
    //   style={StyleSheet.absoluteFill}
    //   device={back!}
    //   isActive={true}
    // />
    <View style={{
      backgroundColor: 'white',
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center'
    }}>
      <Text>
        has permission: {hasPermission ? 'yes' : 'no'}
      </Text>
      <Button
        onPress={() => request()}
        title="request permission"
      />
    </View>
  )
}

Relevant log output

.

Camera Device

.

Device

S22 ultra

VisionCamera Version

4.6.4

Can you reproduce this issue in the VisionCamera Example app?

I didn't try (⚠️ your issue might get ignored & closed if you don't try this)

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions