Hi everyone,
I'm running into an issue with AVAudioRecorder when handling interruptions such as phone calls or alarms.
Problem: When the app is recording audio and an interruption occurs:
I handle the interruption with audioRecorder?.pause()
inside AVAudioSession.interruptionNotification (on .began).
On .ended,
I check for .shouldResume and call audioRecorder?.record()
again.
The recorder resumes successfully, but only the audio recorded after the interruption is saved. The audio recorded before the interruption is lost, even though I'm using the same file URL and not recreating the recorder.
Repro:
- Start a recording with AVAudioRecorder
- Simulate a system interruption (e.g., incoming call)
- Resume recording after the interruption
- Stop and inspect the output audio file
Expected: Full audio (before and after interruption) should be saved.
Actual: Only the audio after interruption is saved; the earlier part is missing
Notes: According to the documentation, calling .record() after .pause() should resume recording into the same file.
I confirmed that the file URL does not change, and I do not recreate the recorder instance.
No error is thrown by the system during this process.
This behavior happens consistently when the app is interrupted and resumed.
Question: Is this a known issue? Is there a recommended workaround for preserving the full recording when interruptions happen?
Thanks in advance!