On 11 September 2018, we made updates to our iOS and Android SDKs. These new SDKs work for both Spotify Free and Spotify Premium users, offer built-in offline support, and more. Read more about the updates on our blog.
Want to access the 2014 iOS streaming SDK? It is available on GitHub by clicking here.

When the App Remote SDK wants to wake up the Spotify client it must perform an app switch to do so. The Spotify client will use the redirect URI you have registered on the developer dashboard to switch back to your app once the user has approved the authorization (or once a token is retrieved if the user has already approved your app). In order to have your app work smoothly with app switching and maintaining a connection we recommend disconnecting App Remote when your app resigns active and reconnecting when your app becomes active like so.

- (void)applicationWillResignActive:(UIApplication *)application {
    if (self.appRemote.isConnected) {
        [self.appRemote disconnect];
    }
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    if (self.appRemote.connectionParameters.accessToken) {
        [self.appRemote connect];
    }
}

Please note that currently an app switch is required to resume playback when the user pauses the music. We recommend having a button that says “Resume Playback” or “Open Spotify” if App Remote is not connected so it’s clear to the user an app switch will occur. You should still show a normal play button if App Remote is connected and the music is paused however.

Token Management

Auth tokens have a predefined time to live, and will eventually expire. This means an app switch flow will be needed to re-authorize your application. We recommend persisting auth tokens and attempting to connect with them before attempting to the re-authorize. If an expired token is used the connection will simply fail and you can use the initial auth flow with the authorizeAndPlayURI: method.