Reputation: 190
Within my Expo project I'm using expo-camera. Both on Android and iOS the camera asks permission before opening it.
But when I try to open the web version of my project on a mobile device browser, the camera access is denied directly without asking. I tried this on an iPhone 12 and a Samsung Galaxy S20. But both didn't ask permission.
Within my code I use the following line to ask for permission:
const [hasPermission, setHasPermission] = useState(null)
useEffect(() => {
;(async () => {
const { status } = await Camera.requestCameraPermissionsAsync()
setHasPermission(status === 'granted')
})()
}, [])
This is how I call the camera component from expo-camera
import { Camera, CameraType } from 'expo-camera'
return (
<Camera ref={ref => set_camera(ref)} type={type} style={{ flex: 1 }}/>
)
How can I make a mobile browser also ask for camera permission and prevent it from denying directly?
Upvotes: 0
Views: 459
Reputation: 785
If you run on a phone (web browser), over WIFI, be sure to use HTTPS
Upvotes: 0