Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[expo-av] Added ability to disable microphone permission #13446

Merged
merged 3 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/expo-av/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### 🎉 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))

### 🐛 Bug fixes

### 💡 Others
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);