Protecting User Privacy

To protect user privacy, your app must ask and receive permission from the user before recording audio. If the user does not grant permission, then only silence is recorded. The system automatically prompts the user for permission when you use a category that supports recording and the app attempts to use an input route.

Requesting Permission to Record Audio

Instead of waiting for the system to prompt the user for permission to record, you can use the requestRecordPermission: method to manually ask for permission. Using this method allows your app to get permission without interrupting the natural flow of the app, resulting in a better user experience.

AVAudioSession.sharedInstance().requestRecordPermission { granted in
    if granted {
        // User granted access. Present recording interface.
    } else {
        // Present message to user indicating that recording
        // can't be performed until they change their preference
        // under Settings -> Privacy -> Microphone
    }
}