SPTSessionManager Class Reference

Inherits from NSObject
Declared in SPTSessionManager.h

Overview

This class manages a Spotify user session, in the form of SPTSession.

  session

The SPTSession for the SPTSessionManager to manage. If no user has been authenticated this will be nil

@property (nullable, nonatomic, strong) SPTSession *session

Declared In

SPTSessionManager.h

  delegate

The SPTSessionManagerDelegate to notify of initiating a session, renewing a session, and/or errors related to a session

@property (nullable, nonatomic, weak) id<SPTSessionManagerDelegate> delegate

Declared In

SPTSessionManager.h

  spotifyAppInstalled

Determine if the Spotify app is installed.

@property (nonatomic, readonly, getter=isSpotifyAppInstalled) BOOL spotifyAppInstalled

Discussion

Will be YES if the Spotify app is installed (and the URL scheme is whitelisted), otherwise is NO. Note: You must whitelist the “spotify” URL scheme in your info.plist LSApplicationQueriesSchemes or this will always be NO

Declared In

SPTSessionManager.h

  alwaysShowAuthorizationDialog

Set this value to YES when debugging to have the Spotify app always show the authorization confirmation screen. You SHOULD NOT set this value to YES in production or your users will always have to confirm.

@property (nonatomic, assign) BOOL alwaysShowAuthorizationDialog

Declared In

SPTSessionManager.h

– initiateSessionWithScope:options:

Initiate the authorization process on iOS 11 and later.

- (void)initiateSessionWithScope:(SPTScope)scope options:(SPTAuthorizationOptions)options

Parameters

scope

The scope to request, e.g. SPTPlaylistReadPrivateScope|SPTUserReadEmailScope if you wish to request read access to private playlists, and read access to the user’s email address.

options

Options bitmask that informs authorization behavior. See SPTSessionManagerDelegate for messages regarding changes in session state.

Declared In

SPTSessionManager.h

– initiateSessionWithScope:options:presentingViewController:

Initiate the authorization process on iOS versions < 11.

- (void)initiateSessionWithScope:(SPTScope)scope options:(SPTAuthorizationOptions)options presentingViewController:(UIViewController *)presentingViewController

Parameters

scope

The scope to request, e.g. SPTPlaylistReadPrivateScope|SPTUserReadEmailScope if you wish to request read access to private playlists, and read access to the user’s email address.

options

Options bitmask that informs authorization behavior.

presentingViewController

The UIViewController to present the login SFSafariViewController on See SPTSessionManagerDelegate for messages regarding changes in session state.

Declared In

SPTSessionManager.h

– renewSession

Attempt to renew the access token, using the refresh token in the current SPTSession which must be valid.

- (void)renewSession

Declared In

SPTSessionManager.h

– initWithConfiguration:delegate:

Create an SPTSessionManager with the provided configuration.

- (instancetype)initWithConfiguration:(SPTConfiguration *)configuration delegate:(nullable id<SPTSessionManagerDelegate>)delegate

Parameters

configuration

An SPTConfiguration object.

delegate

An optional delegate conforming to SPTSessionManagerDelegate.

Return Value

An SPTSessionManager with the desired configuration.

Declared In

SPTSessionManager.h

– application:openURL:options:

Handle openURL callbacks from the AppDelegate

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)URL options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options

Parameters

application

The UIApplication passed into the matching AppDelegate method

URL

The URL to attempt to parse the access token from

options

The options passed in to the matching AppDelegate method

Return Value

Returns YES if SPTSessionManager recognizes the URL and will attempt to parse an access token, otherwise returns NO.

Declared In

SPTSessionManager.h