Timer works fine even in the background (I can read the logs) but method AVAudioRecorder.record() doesn't ... here the scheduled method:
@objc func timer(){
os_log("timer")
if self.audioRecorder == nil {
//...some stuff
self.audioRecorder = try AVAudioRecorder(url: audioFileName, settings: settings)
self.audioRecorder.delegate = self
self.audioRecorder.record()
}
}
the timer settings:
_ = Timer.scheduledTimer(timeInterval: 10.0, target: self, selector: #selector(timer), userInfo: nil, repeats: false)
I have found this issue after iOS 12.4 update.
I use two different instance of AVAudioSession
It works perfectly when the app is in foreground
I play the audio file tapping it and I schedule with timer when to start recorder
So i start music, I move the app in background, the music still play, the timer fires ... BUT the recorder doesn't want to start ..
Maybe a BUG ?