I am trying to write a swift iOS app that will record the users voice. I have wrote the following code in swift however it fails to request mic permissions from the user. It prints granted yet it never records audio and in the settings pane under privacy it does not list the app. How do I request recording permissions in swift?
var session: AVAudioSession = AVAudioSession.sharedInstance()
session.requestRecordPermission({(granted: Bool)-> Void in
if granted {
println(" granted")
session.setCategory(AVAudioSessionCategoryPlayAndRecord, error: nil)
session.setActive(true, error: nil)
self.recorder.record()
}else{
println("not granted")
}
})