With the introduction of iOS 7, applications have to request microphone access when they want to record audio.
How do I check if the application has access to the microphone?
In the iOS 8 SDK I can use the AVAudioSessionRecordPermission
enum, but how do I check this in iOS 7?
Info:
I don't want to request permission, I just want to check if the app has access to the microphone. (Like Location access):
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
// Do something
}
In iOS7
there is no way to get the current status of microphone authorization
.They have given the enum in iOS8
as AVAudioSessionRecordPermission
In iOS7
you have to request permission every time with
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
if (granted) {
NSLog(@"Permission granted");
}
else {
NSLog(@"Permission denied");
}
}];
The same question has been asked before but there is no such api with which you know current status as in iOS8
You can refer Check for mic permission on iOS 7 without showing prompt
Solution:
Another option is you can show the popup
or ask for permission first time and save the states of user option selected in NSUserDefaults
and than onwards do not ask for permission.
From docs you explicitly do not need to call this if each you do not need to get the permission of user.It will automatically called by AVAudioSession
first time when you try to record
Recording audio requires explicit permission from the user. The first time your app’s audio session attempts to use an audio input route while using a category that enables recording (see “Audio Session Categories”), the system automatically prompts the user for permission; alternatively, you can call requestRecordPermission: to prompt the user at a time of your choosing