I have a iOS/watchOS app that gives audio cues, like a metronome, on specific patterns. The intent of the watch app is to have it at the same time as a workout app (ie Strava, Apple Fitness) and/or a music app (Spotify/Apple Music). The app works in the foreground just fine. But if I start another app (i.e. Strava) the haptic feedback and a "ding" continues to play in the background, but the "beep or voice" stops. Beep/voice works fine in iOS when in the background, just not in watchOS.
Audio cues not working when app is in the background
Thanks for the post. I'm not an expert on audio and less when that involves watchOS. So other watchOS engineers are hopefully jumping into the thread soon.
What I know is the behavior you are seeing is due to the strict differences in how watchOS handles background execution and audio compared to iOS.
When your app goes into the background on watchOS, custom audio playback like AVAudioPlayer or AVAudioEngine playing a voice or beep is immediately suspended unless specific background modes and sessions are active. The reason the ping sound and haptics continue is likely because you are triggering them via WKInterfaceDevice.current().play(.notification) or similar system-level calls, which are handled by a separate system and can fire as long as your app has any background execution time.
Since you want your app to play over music apps without stopping them, you must configure your AVAudioSession to mix with other audio. You should also consider using https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions-swift.struct/duckothers if you want music volume to temporarily lower.
What about workout apps? This is the most critical hurdle for your specific use case. If you are currently using an HKWorkoutSession to keep your app alive in the background, it will break when the user opens Apple Fitness or other workout session apps as watchOS only allows one active workout session at a time. If your app has an active workout session and the user starts a run in another workout app, watchOS terminates your workout session, which suspends your app. Extended runtime sessions have time limits, so keep this in mind for long workouts.
Albert Pascual Worldwide Developer Relations.