expo-audio: option to keep haptics working while recording (iOS)
K
Kamronbek Juraev
iOS silences all haptics and system sounds for as long as an app holds a
recording-capable audio session (any category set with allowsRecording). For a
chat app this is painful: recording a voice note is exactly when you want
haptic feedback for things like recording lock and slide-to-cancel, and right
now every haptic in the app goes dead the moment the recorder configures the
session.
Apple has an opt-in for this: AVAudioSession.setAllowHapticsAndSystemSoundsDuringRecording(true).
expo-audio doesn't expose it, so the only way to get it today is a
patch-package patch on the native module (which is what we ship).
Proposal: a boolean on AudioMode, e.g. allowsHapticsAndSystemSoundsDuringRecording,
default false so nothing changes for existing apps. Two details worth knowing
from running this in production:
- The property belongs to the session configuration, so it needs re-asserting
after every setCategory call, not once at startup. A category change drops it.
- There are three setCategory sites in expo-audio as of SDK 57: the
setAudioModeAsync path in AudioModule, AudioRecorder.prepare, and the new
AudioStream (measurement mode). The first two should respect the flag. The
AudioStream one is a judgment call, measurement mode exists to keep the input
clean and the mic picks up the Taptic Engine, which is also why Apple made
muting the default.
Happy to send a PR if the shape gets a thumbs up, we already run the
equivalent change in production.