import React, { useEffect, useState } from 'react'; import { StyleSheet, View, Text, Image } from 'react-native'; import { Camera, CameraPermissionStatus } from 'react-native-vision-camera'; export default function Splash() { const [ cameraPermissionStatus, setCameraPermissionStatus, ] = useState("not-determined"); const [ microphonePermissionStatus, setMicrophonePermissionStatus, ] = useState("not-determined"); useEffect(() => { const checkPermissions = async () => { console.log(`Checking Permission status...`); let [cameraPermission, microphonePermission] = await Promise.all([ Camera.getCameraPermissionStatus(), Camera.getMicrophonePermissionStatus(), ]); console.log( `Check: CameraPermission: ${cameraPermission} | MicrophonePermission: ${microphonePermission}` ); if (cameraPermission !== "authorized") cameraPermission = await Camera.requestCameraPermission(); if (microphonePermission !== "authorized") microphonePermission = await Camera.requestMicrophonePermission(); console.log( `Request: CameraPermission: ${cameraPermission} | MicrophonePermission: ${microphonePermission}` ); setCameraPermissionStatus(cameraPermission); setMicrophonePermissionStatus(microphonePermission); }; checkPermissions(); }, []); return ( Welcome to{'\n'}Vision Camera. Camera Permission: {cameraPermissionStatus} Camera Permission: {microphonePermissionStatus} ); } const styles = StyleSheet.create({ welcome: { fontSize: 38, fontWeight: 'bold', maxWidth: '80%', }, banner: { position: 'absolute', opacity: 0.4, bottom: 0, left: 0, }, container: { flex: 1, backgroundColor: 'white', }, box: { width: 60, height: 60, marginVertical: 20, }, });