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
            })}

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift