Check for mic permission on iOS 7 without showing

2019-02-19 00:51发布

问题:

The only documented method for checking mic permission on iOS 7 that I could find is requestRecordPermission documented on AVAudioSession. https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioSession_ClassReference/Reference/Reference.html#//apple_ref/occ/instm/AVAudioSession/requestRecordPermission:

However, the very act of checking permission using this method will display an alert asking user for permission if user hasn't already made a decision, which can be very undesirable. Is there a work around to check mic permission without showing a prompt?

回答1:

In iOS 8, they added a new property to AVAudioSession:

[AVAudioSession sharedInstance].recordPermission

That returns a AVAudioSessionRecordPermission:

enum {
   AVAudioSessionRecordPermissionUndetermined     = 'undt',
   AVAudioSessionRecordPermissionDenied           = 'deny',
   AVAudioSessionRecordPermissionGranted          = 'grnt'
};
typedef NSUInteger  AVAudioSessionRecordPermission;

But there doesn't seem to be a way in iOS 7.