Audio recording sometime shows error at first time iOS swift
Solution:
First you have to get the userinput for recording audio from userpermissions.If you put the below code when you try recording sometimes it will crash.So must have to add the code inside the appdelegate didfinishlaunching and it will works good.
let session:AVAudioSession = AVAudioSession.sharedInstance()
// ios 8 and later
if (session.responds(to: #selector(AVAudioSession.requestRecordPermission(_:)))) {
AVAudioSession.sharedInstance().requestRecordPermission({(granted: Bool)-> Void in
})}
First you have to get the userinput for recording audio from userpermissions.If you put the below code when you try recording sometimes it will crash.So must have to add the code inside the appdelegate didfinishlaunching and it will works good.
let session:AVAudioSession = AVAudioSession.sharedInstance()
// ios 8 and later
if (session.responds(to: #selector(AVAudioSession.requestRecordPermission(_:)))) {
AVAudioSession.sharedInstance().requestRecordPermission({(granted: Bool)-> Void in
})}
Comments
Post a Comment