Reputation: 69
I put a website in a webview in react native, the website has a permission in using the camera and audio but the issue is, the permission prompt is not showing in the mobile app, i also tried to enable all the permissions of the app, but still i can't record audio/video. what will be the solution for this?
Upvotes: 6
Views: 2733
Reputation: 314
If you are using expo, first install:
expo install expo-camera
Then, in your WebView:
import { Camera } from "expo-camera";
export default function MyWebView({ route }) {
Camera.requestCameraPermissionsAsync();
... your webViewCode ...
}
source: https://docs.expo.dev/versions/latest/sdk/camera/#camerarequestcamerapermissionsasync
Upvotes: 1
Reputation: 1233
You have to use PermissionsAndroid
of React-native to ask for permissions
Following is the code for asking permissions :
async checkPermissions() {
await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.CAMERA,
]).then(result => {
console.log('checkPermissions result', result);
});
}
Provide whatever permissions you require in the array and check for their status in result.
Upvotes: 1