Configuring AVAudioSession to allow "Hey Siri"

I'm building a recording app, and have built an App Shortcut that allows the user to start recording via Siri ("Hey Siri, start a recording").

This works well until the audio session is activated for the first time. After that, the device no longer listens to "Hey Siri".

I'd like to have the following behaviour:

  • while the app is recording, the device should not listen to Siri
  • when the app is not recording, the device should listen to Siri

I've currently configured AVAudioSession this way:

try session.setCategory(.playAndRecord, options: [.defaultToSpeaker, .allowBluetoothA2DP, .allowAirPlay, .mixWithOthers])

I've tried switching the category back and forth between .playAndRecord and .playback when recording/not recording, but that didn't help either.

I'd also like to avoid changing the category or activating/deactivating the audio session, since it always takes a bit of time. When the audio session is configured and/or activated, the user experiences a "slow" record button: there's a noticeable delay between tapping the button and the device actually recording. When it is already configured, the record button starts recording instantly.

What impact does AVAudioSession have on Siri?