I would like to detect when a user refused the microphone permission on my iOS application. I only get this value when I try to record the microphone: -120.000000 db
But before to get this I have to set up an AVAudioSession. Is there another function?
And I got this message in the output: Microphone input permission refused - will record only silence
Thanks.
Allow access to microphone and camera on Android devicesSelect 'Settings > Apps > LINE WORKS' on your device. Select 'Permissions' in App info. Allow access to 'Microphone', 'Phone', and 'Camera'.
You will need to (1) Open Settings (2) Tap Privacy (3) Tap Microphone (4) Tap the Xbox app to allow microphone access.
If you are still compiling with iOS SDK 6.0 (as I am) you have to be a bit more indirect than @Luis E. Prado, as the requestRecordPermission method doesn't exist.
Here's how I did it. Remove the autorelease bit if you're using ARC. On iOS6 nothing happens, and on iOS7 either the 'microphone is enabled' message is logged or the alert is popped up.
AVAudioSession *session = [AVAudioSession sharedInstance]; if ([session respondsToSelector:@selector(requestRecordPermission:)]) { [session performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) { if (granted) { // Microphone enabled code NSLog(@"Microphone is enabled.."); } else { // Microphone disabled code NSLog(@"Microphone is disabled.."); // We're in a background thread here, so jump to main thread to do UI work. dispatch_async(dispatch_get_main_queue(), ^{ [[[[UIAlertView alloc] initWithTitle:@"Microphone Access Denied" message:@"This app requires access to your device's Microphone.\n\nPlease enable Microphone access for this app in Settings / Privacy / Microphone" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil] autorelease] show]; }); } }]; }
EDIT: It turns out that the withObject block is executed in a background thread, so DO NOT do any UI work in there, or your app may hang. I've adjusted the code above. A client pointed this out on what was thankfully a beta release. Apologies for the mistake.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With