Open jadenbanson opened 2 years ago
func appRemote(_ appRemote: SPTAppRemote, didDisconnectWithError error: Error?) {
reconnectSpotify()
}
func reconnectSpotify() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
if !self.appRemote.isConnected {
self.appRemote.connectionParameters.accessToken = self.accessToken
self.appRemote.connect()
self.appRemote.authorizeAndPlayURI("")
}
}
}
My app uses the app remote to subscribe to the players state.
But when iOS terminates the Spotify app in the background after another app plays media, then restarts it after I leave that media, app remote becomes disconnected (via "end of stream").
Right now, my only solution is sending the user a push notification telling them to open my app and press a button to reconnect to app remote, which is bad for UX.
Is there anyway to automatically reconnect app remote when the Spotify app resumes playback?