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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
On iOS, Expo Camera requires NSMicrophoneUsageDescription key to use the feature #11736
Comments
I am getting the same error |
I also faced this problem and did some work around like this. in I changed it from - (NSDictionary *)getPermissions
{
AVAuthorizationStatus systemStatus;
UMPermissionStatus status;
NSString *cameraUsageDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSCameraUsageDescription"];
NSString *microphoneUsageDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSMicrophoneUsageDescription"];
if (!(cameraUsageDescription && microphoneUsageDescription)) {
UMFatal(UMErrorWithMessage(@"This app is missing either NSCameraUsageDescription or NSMicrophoneUsageDescription, so audio/video services will fail. Add one of these entries to your bundle's Info.plist."));
systemStatus = AVAuthorizationStatusDenied;
} else {
systemStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
}
// ... to be - (NSDictionary *)getPermissions
{
AVAuthorizationStatus systemStatus;
UMPermissionStatus status;
NSString *cameraUsageDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSCameraUsageDescription"];
if (!cameraUsageDescription) {
// changed a bit of its exception
UMFatal(UMErrorWithMessage(@"This app is missing either NSCameraUsageDescription. Add this entry to your bundle's Info.plist."));
systemStatus = AVAuthorizationStatusDenied;
} else {
systemStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
}
// ... I'm sure this is not a good practice. I guess we may need a new prop to let the component knows whether it needs a check for using video or not (in that case, it has to check for NSMicrophone) or should we separate the component for Video and Camera? |
Any updates? |
I'm also seeing this issue in a bare project that was ejected from a managed app that worked perfectly. I also checked Info.plist and the NSCameraUsageDescription is present but NSMicrophoneUsageDescription is not because the app does not use the microphone. |
I ran into the same issue with a bare RN project, it's a bit misleading since the docs say that microphone is optional. But looking at @gie3d's comment suggests otherwise. |
Confirming as well. When using only the Camera for QR Code scan
Pushing to TestFlight - the error occurs - "Use camera" prompt doesn't pop up |
I have the same error. It's detected locally when using Xcode 12.4/iOS 14.4 and an iPhone 11. |
For now, the safest option is to specify the I did some digging and it seems that the microphone permission prompt will only show if you use any sort of audio component with the camera. For something like the BarcodeScanner, this shouldn't ever really happen because it doesn't need to capture audio. However, if you're using the If you don't want to record audio, then specifying The takeaways are that the One downside to requiring all users specify a microphone permission in I think we should extend the |
We might try patching via https://www.npmjs.com/package/patch-package or something based on |
Update re: trying to using a patch via patch-package Applying a patch via patch-package isn't working We cleaned the our project using Applied the patch - checked the node_modules dir to ensure the patch was applied + ran builds across multiple computers. Somehow we're still seeing the
vs the patched We're are using a React Native project vs an expo project - could it be something to do with react-native-unimodules ?
|
@timarney - i'll try this in a new repository and report back in a moment |
ah sorry - my bad. i forgot to mention that by default we compile xcframeworks of expo packages at publish time, so that developers using them have faster builds. if you patch a module and want to build it from source, then you can disable this either for all modules or on a per-module basis in your Podfile: https://github.com/brentvatne/microphone-permissions/blob/7ad6815caf90a2d283cf6c1cd81d6cb117bdc002/ios/Podfile#L7-L12
confirmed that everything works well with your patch in this repo (although i had installed expo-barcode-scanner@10.1.2 there, your patch still applied cleanly and the issue reprod before the above podfile fix) |
Nice we'll also we updating to expo-barcode-scanner@10.1.2 Thanks for hunting that down @brentvatne
|
We don't use expo-barcode-scanner so using that as a solution didn't work. I had to add the microphone permission to get around this issue. Is there a fix planned to fix this to not require the microphone if an app doesn't need it? |
@WilbertJanney - you use expo-camera then or what? if so, you can cherry-pick the changes from this pr and follow the |
I'm also seeing this using |
@rdsedmundo which version of this package are you using? Those functions should be available in ref: https://github.com/expo/expo/blob/master/packages/expo-camera/CHANGELOG.md |
@ajsmth 11.0.3, that's the one tagged as latest on NPM, although now that you said I can see that there's a 11.1.0 available. Is that expected? |
I believe we'll need to promote to the latest version - you can install this version explicitly in the meantime |
Sorry, I removed my recent comment as I still observe the problem I changed
which was defined in It would be nice if
|
@gie3d - what sdk version are you using? or expo-camera version? |
@brentvatne i tested with
|
@gie3d hey there - I've just tested this on SDK 42 and it seems to be working fine - you can check out a repro here: https://github.com/ajsmth/expo-camera-sdk-42 That error message should only be coming from |
@ajsmth many thanks for the information. I'll fine time this weekend to test it out. Btw, looked into your repo and found that the primary different between this and my code is that I open the camera I'll fork your project and reproduce the problem and then I'll get back again. |
@gie3d did your problem go away or are you still having issues? I might have reproduced a similar situation to yours - let me know! |
@ajsmth I tested on a newly forked repo (https://github.com/gie3d/expo-camera-sdk-42) in bare workflow and it seems working correctly. I saw you mentioned this issue in a PR. Could you share if you can reproduce this issue. |
This is a logical issue in the written code. Permissions should be checked based on the media types the user is requesting. If the media type is just for image, microphone permission should be dismissed.
|
@matinzd I agree. Our app uses expo-image-picker to select user's profile picture. We don't need microphone permission, but the app crashes when opening camera. With this plugin setting:
This is an issue when apple is reviewing the app, since the app has setup unnecessary permission. For now, the hotfix is to add this patch file: index 3cc81e0f8a4d1804ef42c5ee632527597f890950..ae0db1900d70f627ab50d7a75edd152e48151b9d 100644
--- a/ios/ImagePickerPermissionRequesters.swift
+++ b/ios/ImagePickerPermissionRequesters.swift
@@ -18,8 +18,7 @@ public class CameraPermissionRequester: NSObject, EXPermissionsRequester {
var systemStatus: AVAuthorizationStatus
var status: EXPermissionStatus
let cameraUsageDescription = Bundle.main.object(forInfoDictionaryKey: "NSCameraUsageDescription")
- let microphoneUsageDescription = Bundle.main.object(forInfoDictionaryKey: "NSMicrophoneUsageDescription")
- if cameraUsageDescription == nil || microphoneUsageDescription == nil {
+ if cameraUsageDescription == nil {
EXFatal(EXErrorWithMessage("""
This app is missing either 'NSCameraUsageDescription' or 'NSMicrophoneUsageDescription', so audio/video services will fail. Ensure both of these keys exist in app's Info.plist. |
I am getting the same error here as @kaladivo . Seems to still be an issue |
Same here. Using expo-image-picker v14.3.2 & Expo v49 to allow user to take photos directly. Works in Expo Go but crashes on a physical device in TestFlight. Seems like a bug or a regression in Expo. Was able to work around it by giving a permission string value to |
Hi @jonrh Jut in case you come back here
I then added it to my app,json plugin section
And set the "microphonePermission": false in the expo-image-picker plugin as well |
@ryonwhyte can you elaborate a little on your code or any other suggestions? I've tried using this code, I've tried setting both the expo-image-picker plugin "microphonePermission" to a string as well as false, and also setting the "NSMicrophoneUsageDescription" to string, and my app still crashes once built for preview or testflight. Using SDK 50 and expo-image-picker 14.7.1. Pulling my hair out as no build works with any variations of these options set or not set. |
@highmountainmedia I think you may be having another issue.
|
@ryonwhyte I finally got this working with using your script, but had to put a string value in for the microphonePermission entry. That's the only way it would not crash. |
Hmm. Thats interesting. I have not encountered any issues. I will test in production and see. Thanks for sharing @highmountainmedia |
@highmountainmedia Yeah my new build on expo 50 is crashing now. I changed "microphonePermission": to a string in my app.json. Did you edit the config plugin? |
馃悰 Bug Report
Summary of Issue
Hi, I just started using Expo Camera on my bare RN project and facing some issues.
I followed the installation process here and according to Configure for iOS, I only need to add
NSCameraUsageDescription
key but doing so produces following error:But adding
NSMicrophoneUsageDescription
key solves the error.I simply copied the code from here and I believe it shouldn't require permission for mic since I'm not going to use camera to take a video. So it should rather considered optional.
Environment - output of
expo diagnostics
& the platform(s) you're targetingSteps to Reproduce
The text was updated successfully, but these errors were encountered: