1

I'm building a React Native app that plays audio using react-native-track-player. Everything works well when the audio is actively playing — I can see the media widget on the lock screen, control playback, and even see track metadata.

However, the problem is that once I pause the audio, the lock screen widget disappears or gets replaced by the system’s default media widget (like Spotify, YouTube, or Apple Music). I want the widget to stay visible and consistent, even when the audio is paused, just like how other music apps behave.

What I’ve tried:

  • Setting alwaysPauseOnInterruption: false and other playback options in updateOptions

  • Configuring capabilities like Capability.Play, Capability.Pause, Capability.Stop, etc.

  • Setting compactCapabilities

  • Setting up the player with waitForBuffer: true and other setupPlayer config options

  • Tried maintaining audio session in native iOS code to prevent session from ending

But none of these helped — the widget still disappears or switches after pause.

await TrackPlayer.updateOptions({
  stopWithApp: false,
  capabilities: [
    Capability.Play,
    Capability.Pause,
    Capability.Stop,
    Capability.SkipToNext,
    Capability.SkipToPrevious,
  ],
  compactCapabilities: [Capability.Play, Capability.Pause],
  alwaysPauseOnInterruption: false,
});

Device Info:

  • iPhone 13, iOS 17.x

  • App is built using React Native CLI (not Expo)

  • Using Xcode for builds and debugging


My Goal:

I want the lock screen media widget to remain visible even when audio is paused, like other audio apps (Spotify, YouTube Music, etc.).


Any suggestions or workarounds to keep the lock screen widget persistent during pause would be greatly appreciated!

1 Answer 1

0

To have the lock screen widget visible / be the Now Playing app, you need to be playing audio (there are other things too, but you're already doing them, if indirectly).

So the solution is to not pause the audio! Or if you must pause your audio, make sure to play something else, like waiting music or silence for as long as you want the lock screen to hang around.

NOTE that this also gets you unlimited background processing (because you need the background audio mode to make the lock screen work at all on iOS) and that can make your app a bad citizen. Who wants to drain their battery to listen to silence?

Playing silence isn't explicitly forbidden by Apple's appstore review guidelines, but it's implied:

2.5.4ASR & NR Multitasking apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion, local notifications, etc.

Facebook's app earned some notoriety a decade or so ago for "accidentally" doing this. You might have luck debating whether or not 2.5.4 applies to your audio app.

An interesting case is the iOS Spotify app which has a mode where you can remote control playback of a spotify instance on another device using the iOS app itself, including via the lockscreen. The app is not obviously producing audio, yet the lock screen remains. Either this is done via the silence hack or with special treatment from Apple. Special treatment could include a discussion with the review team or a hypothetical special entitlement that lets you keep the app keep the lock screen without wastefully playing silence.

I haven't tried the youtube app.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.