Keeping a microphone alive all night on iOS sounds trivial and is not. Some field notes from building an audio-first sleep tracker, for anyone fighting the same OS behaviors.
The problem
iOS suspends backgrounded apps aggressively. An AVAudioSession with the playAndRecord category keeps you alive - until the user locks the phone, another app grabs the session, or the system decides you are idle. Result: silent gaps in the night you only discover in the morning.
What actually works
A keep-alive audio node. A muted output node on the audio graph signals "actively doing audio" to the OS. Without it, recording-only sessions get reaped on lock on some OS versions.







