1import { 2 AndroidConfig, 3 ConfigPlugin, 4 createRunOncePlugin, 5 withInfoPlist, 6} from 'expo/config-plugins'; 7 8const pkg = require('expo-av/package.json'); 9 10const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone'; 11 12const withAV: ConfigPlugin<{ microphonePermission?: string | false } | void> = ( 13 config, 14 { microphonePermission } = {} 15) => { 16 if (microphonePermission !== false) { 17 config = withInfoPlist(config, (config) => { 18 config.modResults.NSMicrophoneUsageDescription = 19 microphonePermission || config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE; 20 return config; 21 }); 22 } 23 24 return AndroidConfig.Permissions.withPermissions( 25 config, 26 [ 27 microphonePermission !== false && 'android.permission.RECORD_AUDIO', 28 'android.permission.MODIFY_AUDIO_SETTINGS', 29 ].filter(Boolean) as string[] 30 ); 31}; 32 33export default createRunOncePlugin(withAV, pkg.name, pkg.version); 34