AVAudioRecorder starts recording only first time after granting microphone permissions with Siri Intent

AVAudioRecorder.record()
returns
true
only first time after granting permission to microphone with system alert, than it always return
false
. How to make AVAudioRecordenr record on the second and others app launch?

Already tried adding

NSMicrophoneUsageDescription
to info.plist and requesting
AVAudioSession
requestRecordPermission
from code. The funny thing that this code works on main target, but have this wierd behavoir on Siri UI Intent.


Here is the code:

func startRecording() {
        let dirPath =  try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
        let recordName = "record.m4a"
       
        self.audioURL = dirPath.appendingPathComponent(recordName)
        let session = AVAudioSession.sharedInstance()
        let microPhoneStatus = AVCaptureDevice.authorizationStatus(for: AVMediaType.audio)
        print(microPhoneStatus)
            do {
                try session.setCategory(AVAudioSession.Category.playAndRecord, mode: AVAudioSession.Mode.default, options: AVAudioSession.CategoryOptions.duckOthers)
            } catch {
                print(error)
            }
       
            let recordSettings = [ AVFormatIDKey : kAudioFormatAppleLossless,
                               AVEncoderAudioQualityKey : AVAudioQuality.low.rawValue,
                               AVEncoderBitRateKey: 320000,
                               AVNumberOfChannelsKey : 2,
                               AVSampleRateKey : 44100.0 ] as [String : Any]
       
            guard let recorder  = try? AVAudioRecorder(url: self.audioURL, settings: recordSettings) else {
                self.finishRecording(success: false)
                return
            }
       
            self.audioRecorder = recorder
            self.audioRecorder.isMeteringEnabled = true
            self.audioRecorder.delegate = self
            let isDeleted = self.audioRecorder.deleteRecording()
            let isPrepared = self.audioRecorder.prepareToRecord()
            try! session.setActive(true)
            let isRecordStarted = self.audioRecorder.record()

    }

There question is why audioRecorder.record() returns 'true' only first time after tapped "allow" on microphone permissions alert and rest of the times it returns 'false' and recording does not started.