diff --git a/packages/expo-av/CHANGELOG.md b/packages/expo-av/CHANGELOG.md index c19d8220ec7275..a52d12f7da8d16 100644 --- a/packages/expo-av/CHANGELOG.md +++ b/packages/expo-av/CHANGELOG.md @@ -6,6 +6,7 @@ ### 🎉 New features +- [plugin] Added ability to disable microphone permission via `microphonePermission: false`. ([#13446](https://github.com/expo/expo/pull/13446) by [@EvanBacon](https://github.com/EvanBacon)) - Add web support for recording. ([#8721](https://github.com/expo/expo/pull/8721) by [@WazzaJB](https://github.com/WazzaJB) and [@mnightingale](https://github.com/mnightingale)) - Add permissions support for web. ([#8721](https://github.com/expo/expo/pull/8721) by [@mnightingale](https://github.com/mnightingale)) diff --git a/packages/expo-av/plugin/build/withAV.d.ts b/packages/expo-av/plugin/build/withAV.d.ts index a8ab4a8f343efb..5cdc30bab130e2 100644 --- a/packages/expo-av/plugin/build/withAV.d.ts +++ b/packages/expo-av/plugin/build/withAV.d.ts @@ -1,5 +1,5 @@ import { ConfigPlugin } from '@expo/config-plugins'; declare const _default: ConfigPlugin; export default _default; diff --git a/packages/expo-av/plugin/build/withAV.js b/packages/expo-av/plugin/build/withAV.js index 0d88b241e48ef4..a5f9e80a677f0a 100644 --- a/packages/expo-av/plugin/build/withAV.js +++ b/packages/expo-av/plugin/build/withAV.js @@ -4,14 +4,16 @@ const config_plugins_1 = require("@expo/config-plugins"); const pkg = require('expo-av/package.json'); const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone'; const withAV = (config, { microphonePermission } = {}) => { - config = config_plugins_1.withInfoPlist(config, config => { - config.modResults.NSMicrophoneUsageDescription = - microphonePermission || config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE; - return config; - }); + if (microphonePermission !== false) { + config = config_plugins_1.withInfoPlist(config, config => { + config.modResults.NSMicrophoneUsageDescription = + microphonePermission || config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE; + return config; + }); + } return config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [ - 'android.permission.RECORD_AUDIO', + microphonePermission !== false && 'android.permission.RECORD_AUDIO', 'android.permission.MODIFY_AUDIO_SETTINGS', - ]); + ].filter(Boolean)); }; exports.default = config_plugins_1.createRunOncePlugin(withAV, pkg.name, pkg.version); diff --git a/packages/expo-av/plugin/src/withAV.ts b/packages/expo-av/plugin/src/withAV.ts index bdee427a648b1e..a082582524a609 100644 --- a/packages/expo-av/plugin/src/withAV.ts +++ b/packages/expo-av/plugin/src/withAV.ts @@ -9,20 +9,25 @@ const pkg = require('expo-av/package.json'); const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone'; -const withAV: ConfigPlugin<{ microphonePermission?: string } | void> = ( +const withAV: ConfigPlugin<{ microphonePermission?: string | false } | void> = ( config, { microphonePermission } = {} ) => { - config = withInfoPlist(config, config => { - config.modResults.NSMicrophoneUsageDescription = - microphonePermission || config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE; - return config; - }); + if (microphonePermission !== false) { + config = withInfoPlist(config, config => { + config.modResults.NSMicrophoneUsageDescription = + microphonePermission || config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE; + return config; + }); + } - return AndroidConfig.Permissions.withPermissions(config, [ - 'android.permission.RECORD_AUDIO', - 'android.permission.MODIFY_AUDIO_SETTINGS', - ]); + return AndroidConfig.Permissions.withPermissions( + config, + [ + microphonePermission !== false && 'android.permission.RECORD_AUDIO', + 'android.permission.MODIFY_AUDIO_SETTINGS', + ].filter(Boolean) as string[] + ); }; export default createRunOncePlugin(withAV, pkg.name, pkg.version);