Announcements

Help Wizard

Step 1

NEXT STEP

SpotifyAppRemote Disconnects After Idle Despite Valid Access Token

SpotifyAppRemote Disconnects After Idle Despite Valid Access Token

I'm using Spotify playback in my iOS app.

I'm using the Spotify iOS SDK, following the pattern shown in NowPlayingView. Everything works correctly at first:

  • Authorization flow completes
  • Remote playback starts via SPTAppRemote
  • App correctly receives playback state and metadata

🐞Problem:
After I pause playback, if I wait a few seconds, I consistently receive a disconnection callback from the SDK:
func appRemote(_ appRemote: SPTAppRemote, didDisconnectWithError error: Error)

This happens even while the app is fully active and foregrounded — not backgrounded, killed, or suspended.

Here is the actual debug output:
[SpotifyManager] 🔴 appRemote disconnected with error:
• Description: Connection terminated.
• Code: -1002
• Domain: com.spotify.app-remote
• Failure Reason: The Spotify app might have been suspended.
• Recovery Suggestion: Try to reconnect.
• Underlying Error: End of stream.
• Underlying Failure Reason: One of the streams has reached the end.
• Underlying Recovery Suggestion: Reconnect to the Spotify app.

What I’ve Verified:

  • The Spotify app is open and active (not backgrounded or closed)
  • My app is also in foreground
  • Network is stable, no major background tasks running
  • I am not calling disconnect() manually
  • Valid Access Token

💥Impact
After this disconnection, I cannot control playback anymore.

To restore control, the user must go through the full authorisation and reconnection flow again, which results in a disrupted and unintuitive user experience.

Please let us know:

  • Is there a recommended way to prevent this disconnection after pause?
  • How can we recover control without forcing full re-authentication?

This issue is blocking us from delivering a stable and seamless playback experience to users.

Any clarification or workaround would be greatly appreciated.

Reply
1 Reply

Having the exact same issue with my app. It's a really poor implementation on Spotify's part IMO. The SDK should have an option to make your app "another device" or something so you can control playback from it. For example, when I have spotify playing through my phone, I can open the spotify app up on my computer and hit "next track" and my phone will stay in sync. If you could register your app as another "device" like this, it could just be in sync with everything else.

 

I'm going to test and see if a "heartbeat" play/pause will keep it active - will report back.

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 5 years ago  in Social & Random