Search code examples
iosswiftspotify

How to use ''SpotifyiOS" framework and Authorize app without acutally playing a song


I am using 'SpotifyiOS' framework recommended by Spotify (https://github.com/spotify/ios-sdk) to access their APIs. To login/Authorise the App we must login to Spotify and it is invoked by following available methods:

appRemote.authorizeAndPlayURI(..

where appRemote is an instance of SPTAppRemote

It plays a song even if I pass empty String as URI as shown below:

enter image description here

How can I authorise app without playing any song using 'SpotifyiOS' famework?


Solution

  • You can use the SPTSessionManager to authenticate without playing a song.

    The flow is a bit more convoluted and better followed at the documentation link than copy/pasted here, but in short you configure the SPTSessionManager and provide it a delegate that on successful authentication provides a token to your SPTAppRemote which can then be used to control the application.