Requests the user’s permission to record audio.
- iOS 7.0+
- Mac Catalyst 13.0+
- watchOS 4.0+
A block, of type
Permission, whose sole parameter contains a Boolean value indicating whether the user granted or denied permission to record.
When you call this method, if the user previously granted or denied recording permission, the block executes immediately without displaying a recording permission alert. If the user hasn’t yet granted or denied permission when you call this method, the system displays a recording permission alert and executes the block after the user responds to it.
Recording audio requires explicit permission from the user. The first time your app’s audio session attempts to record from an audio input, the system automatically prompts the user for permission. You can explicitly ask earlier by calling this method. Until the user grants your app permission to record, your app records only silence. When a user responds to a recording permission prompt for your app, the system remembers the choice. If the user has denied recording permission, they can reenable it in Settings > Privacy > Microphone.
This method returns immediately, but the
response block waits for user input if the user hasn’t previously granted or denied recording permission.
The framework may call the thread from a different thread context. Dispatch back to the main thread for any changes that update the user interface.