How to detect user giving microphone permission on iOS?

后端 未结 2 404
别跟我提以往
别跟我提以往 2021-01-13 00:22

So the thing is that I need to call some function after user gives (or declines) a permission to use the microphone.

I already saw this:

[[AVAudioSes         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-13 00:57

    If use has not yet given your permission, do the following:

    1. First, show the popup dialogue
    2. Run your code in OP

    -

    if([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission)]) {
        [[AVAudioSession sharedInstance] requestRecordPermission];
        // Now run your function
    }
    

提交回复
热议问题