1

I need to check the permission of a React Page. This page is inside a webview. the mobile app that use the webview is made in React-Native. I used <WebView> from the library react-native-webview

this is my permission request inside the React Page

  const checkPermissions = () => {
    try {
      const permissions = navigator.mediaDevices.getUserMedia({ audio: true });
      permissions
        .then((stream) => {
          console.log('permission granted');
        })
        .catch((e) => {
          console.log('permission denied');
        });
    } catch (e) {
      console.log(e);
      alert(e);
    }
  };

this is the WebView

<WebView
 source={{ uri:'Http://192.168.1.138:3000/#/permissionTestPage' }}
 onNavigationStateChange={onNavigationStateChange}
 originWhitelist={['*']}  
 allowsInlineMediaPlayback={true} 
 mediaPlaybackRequiresUserAction={false} 
 javaScriptEnabled={true} 
 domStorageEnabled={true}
 mediaCapturePermissionGrantType='grantIfSameHostElsePrompt'
/>

this is the error on the mobile device that opened the webview enter image description here

  • Maybe related to https://stackoverflow.com/questions/60957829/navigator-mediadevices-is-undefined – Nico.S Nov 30 '22 at 11:28

0 Answers0