Requests the user’s permission, if needed, for recording a specified media type.
- iOS 7.0+
- macOS 10.14+
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
YESis returned; otherwise
NO. The block will return immediately.
Recording audio or video always requires explicit permission from the user. The first time you create any
AVCapture 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
AVCapture 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.
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.