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:campaign:

Initiate the authorization process

- (void)initiateSessionWithScope:(SPTScope)scope options:(SPTAuthorizationOptions)options campaign:(nullable NSString *)campaign

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.

campaign

The campaign identifier, to help attribute where the account linking was initiated from. See SPTSessionManagerDelegate for messages regarding changes in session state.

Declared In

SPTSessionManager.h

– initiateSessionWithRawScope:options:campaign:

Initiate the authorization process

- (void)initiateSessionWithRawScope:(NSString *)scope options:(SPTAuthorizationOptions)options campaign:(nullable NSString *)campaign

Parameters

scope

The scope to request, e.g. "playlist-read-private user-read-email" 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.

campaign

The campaign identifier, to help attribute where the account linking was initiated from. See SPTSessionManagerDelegate for messages regarding changes in session state.

Discussion

Note: Prefer initiateSessionWithScope:options:campaign instead, unless you need additional scopes that aren’t listed in SPTScope

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

– application:continueUserActivity:restorationHandler:

Handle continueUserActivity callbacks from the AppDelegate

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void ( ^ ) ( NSArray<id<UIUserActivityRestoring> > *__nullable restorableObjects ))restorationHandler

Parameters

application

The UIApplication passed into the matching AppDelegate method

userActivity

An object encapsulating a user activity supported by this responder.

restorationHandler

A block to execute if your app creates objects to perform the task the user was performing

Return Value

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

Declared In

SPTSessionManager.h