如何在RN CLI项目中移除React-Native-Camera的录音权限
Fixing Unwanted Audio Permission Request in react-native-camera for Avatar Capture
Hey there! I totally get the frustration of seeing an audio permission popup when your app doesn't even need recording functionality. Let's walk through the steps to get rid of that once and for all.
First, you're already on the right track by setting captureAudio={false} on your RNCamera component—this tells the library not to use audio capture. But the issue likely comes from native platform configuration where the audio permission is still declared by default. Here's how to fix it for both Android and iOS:
Android Solution
- Open your project's
android/app/src/main/AndroidManifest.xmlfile. - First, make sure your root
<manifest>tag includes the tools namespace (add this if it's missing):<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.yourappname"> - Add this line inside the
<manifest>tag to explicitly remove the defaultRECORD_AUDIOpermission that react-native-camera might be adding:<uses-permission android:name="android.permission.RECORD_AUDIO" tools:node="remove" /> - Clean and rebuild your Android project to apply the changes:
cd android && ./gradlew clean && cd .. && npx react-native run-android
iOS Solution
- Navigate to
ios/[YourAppName]/Info.plist(replace[YourAppName]with your actual app name). - Look for the key
NSMicrophoneUsageDescription—this is what triggers the microphone permission popup. Delete this entire entry (both the key and its value). - Clean up your iOS dependencies and rebuild:
cd ios && pod deintegrate && pod install && cd .. && npx react-native run-ios
Additional Checks
- Double-check that your
RNCameracomponent still hascaptureAudio={false}set (you already have this in your code, which is perfect). - If you're using an older version of react-native-camera, consider upgrading to the latest stable release—some older versions had bugs where
captureAudio={false}didn't properly suppress the permission request.
That should do it! Your app will now only request camera permission, and the audio popup will be gone.
内容的提问来源于stack exchange,提问作者Bharath-CODER
相关产品推荐
相关产品推荐

