Type Method


Requests the user’s permission, if needed, for recording a specified media type.


class func requestAccess(for mediaType: AVMediaType, completionHandler handler: @escaping (Bool) -> Void)



A media type constant, either video or audio. If no media type is supplied, an invalidArgumentException will be thrown.


A block to be called once permission is granted or denied.

The completion handler is called on an arbitrary dispatch queue. It is the client's responsibility to ensure that any UIKit-related updates are called on the main queue or main thread as a result.

The block receives the following parameter:


If the user grants permission to use the hardware true is returned; otherwise false. The block will return immediately.


Recording audio or video always requires explicit permission from the user. The first time you create any AVCaptureDeviceInput objects for a media type that requires permission, the system automatically displays an alert to request recording permission. Alternatively, you can can call this method to prompt the user at a time of your choosing.

This call will not block while the user is being asked for access, allowing the client to continue running. Until access has been granted, any AVCaptureDevices for the media type will vend silent audio samples or black video frames. The user is only asked for permission the first time the client requests access. Later calls use the permission granted by the user.

After the user grants recording permission, the system remembers the choice for future use in the same app, but the user can change this choice at any time using the Settings app. If the user has denied your app recoding permission or has not yet responded to the permission prompt, any audio recordings will contain only silence and any video recordings will contain only black frames.

The response parameter is a block whose sole parameter indicates whether the user granted or denied permission to record. This method always returns immediately. If the user has previously granted or denied recording permission, it executes the block when called; otherwise, it displays an alert and executes the block only after the user has responded to the alert.

Invoking this method with audio is equivalent to calling the AVAudioSession method requestRecordPermission(_:).

See Also

Verifying Authorization

class func authorizationStatus(for: AVMediaType) -> AVAuthorizationStatus

Returns a constant indicating whether the app has permission for recording a specified media type.

enum AVAuthorizationStatus

Constants that provide information regarding permission to use media capture devices.