Reputation: 239
I am building a web-based app with React-Native and Expo. It uses the WebView to display a website that will record though the microphone. However I cannot find a way for the app to request Microphone access. If I access this website via browser, it will ask for microphone access.
I have tried adding the permissions to the AndroidManifest File.
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.MICROPHONE" />
<uses-feature android:name="android.hardware.microphone" android:required="true" />
Despite all that, it still does not request microphone access, and as a result the website will not load (since it can't detect a microphone). Is there any other way for me to access the Microphone in React Native's WebView Component? Thanks a bunch!
Upvotes: 7
Views: 11663
Reputation: 3540
You can use expo-av to ask for mic permissions. I found this amazing because I wanted to use react-native-voice and I had to eject my project to do so. Afterwards, I did absolutely nothing to the android manifest file and the app still requested permissions and everything.
Upvotes: 0
Reputation: 19
Please refer to the below link.
https://github.com/Unapedra/rn-android-permission-webview
It contains the component that just implements the function onPermissionRequest() of Android Webviews, so the user is asked to grant permission on camera, mic, etc. on the web. Native Webviews for ReactNative do not have this function implemented, and thus, nothing is asked to the user (it just fails and denies the permission silently).
The sample code is given in that link.
Upvotes: 1