Instance Method

requestRecordPermission(_:)

Requests the user’s permission for audio recording.

Declaration

func requestRecordPermission(_ response: @escaping PermissionBlock)

Parameters

response

A block, of type PermissionBlock, whose sole parameter contains a Boolean value indicating whether the user granted or denied permission to record.

If, when you call this method, the user had previously granted or denied recording permission, the block executes immediately and without displaying a recording permission alert.

If the user has not 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.

Discussion

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, 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 can record only silence.

This method always returns immediately, but the response block awaits user input if the user has not previously granted or denied permission to record in your app.

The block may be called in a different thread context.

Topics

Data Types

typealias PermissionBlock

The signature for the block executed when the user responds to a system prompt for recording permission.

See Also

Requesting Permission to Record

var recordPermission: AVAudioSession.RecordPermission

Returns the current recording permission status.