Skip to content

Commit

Permalink
[expo-av] Added ability to disable microphone permission (expo#13446)
Browse files Browse the repository at this point in the history
* added ability to disable microphone permission

* Update CHANGELOG.md
  • Loading branch information
EvanBacon authored and Felipe committed Sep 18, 2021
1 parent f3f1d26 commit 7003845
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions packages/expo-av/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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))
- Add Audio `usePermissions` hook from modules factory. ([#13851](https://github.com/expo/expo/pull/13851) by [@bycedric](https://github.com/bycedric))
Expand Down
2 changes: 1 addition & 1 deletion packages/expo-av/plugin/build/withAV.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions packages/expo-av/plugin/build/withAV.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions packages/expo-av/plugin/src/withAV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 7003845

Please sign in to comment.