WatchOS: Can a background metronome app coexist with both Runna workout and Spotify playback?

I’m building a standalone Apple Watch metronome app for running.

My goal is for these 3 apps to work at the same time:

  • Runna owns the workout session
  • Spotify plays music
  • my app plays a metronome click in the background

So far this is what I've found:

  • Using HKWorkout​Session in my metronome app works well with Spotify, but conflicts with Runna and other workout apps, so I removed that.
  • Using watchOS background audio with longFormAudio allows my app run in the background, and it can coexist with Runna. However, it seems to conflict with Spotify playback, and one app tends to stop the other.

Is there any supported watchOS audio/background configuration that allows all 3 at once?

More specifically this is what I need:

  1. another app owns HKWorkout​Session
  2. Spotify keeps playing
  3. my app keeps generating metronome clicks in the background

Or is this simply not supported by current watchOS session/background rules?

My metronome uses AVAudio​Engine / AVAudio​Player​Node with generated click audio.

Thank you!

Answered by DTS Engineer in 880518022

If you are looking for a way to have multiple apps running their own active HKWorkoutSession on watchOS simultaneously, there is no way to do that. This is documented here:

"Apple Watch runs one workout session at a time. If a second workout starts while your workout is running, your HKWorkoutSessionDelegate object receives an HKError.Code.errorAnotherWorkoutSessionStarted error, and your session ends."

Regarding audio, my limited knowledge is that, with AVAudioSession, you can tell the system how to mix your app's audio with the current now-playing app by setting up the session category. You can play with the categories and see if there is one fitting your use case.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Also submitted a feedback here FB22273077

If you are looking for a way to have multiple apps running their own active HKWorkoutSession on watchOS simultaneously, there is no way to do that. This is documented here:

"Apple Watch runs one workout session at a time. If a second workout starts while your workout is running, your HKWorkoutSessionDelegate object receives an HKError.Code.errorAnotherWorkoutSessionStarted error, and your session ends."

Regarding audio, my limited knowledge is that, with AVAudioSession, you can tell the system how to mix your app's audio with the current now-playing app by setting up the session category. You can play with the categories and see if there is one fitting your use case.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

WatchOS: Can a background metronome app coexist with both Runna workout and Spotify playback?
 
 
Q