Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't access to camera through react-native-webview

I am using react-native-webview version 4.0.2 . So I have a webview that contains an add button that allows us to take picture with the camera but when clicking at that button nothing is shown and no camera permission shown. This is on android side but working very well on ios (i can see permission and access to camera ).

In my AndroidManifest.xml I do have :

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> 

So please do you have any suggestion ?

like image 808
stuudd Avatar asked Sep 08 '26 00:09

stuudd


1 Answers

1st step: use this in AndroidManifest.xml file

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

2nd step: Grant multiple permission in App.js file

const granted = await PermissionsAndroid.requestMultiple([
  PermissionsAndroid.PERMISSIONS.CAMERA,
  PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
  PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
]);

3rd step: use these properties inside webview

geolocationEnabled={true}
mediaPlaybackRequiresUserAction={false}
javaScriptEnabled={true}
like image 147
zarif rahman Avatar answered Sep 10 '26 14:09

zarif rahman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!