SPTAppRemote Class Reference

Inherits from NSObject
Declared in SPTAppRemote.h

Overview

The SPTAppRemote is the main entry point for interacting with the Spotify app using the Spotify App Remote for iOS.

– initWithConnectionParameters:logLevel:

Initializes a new App Remote.

- (instancetype)initWithConnectionParameters:(SPTAppRemoteConnectionParams *)connectionParameters logLevel:(SPTAppRemoteLogLevel)logLevel

Parameters

connectionParameters

The parameters to use during connection.

logLevel

The lowest severity to log to console.

Return Value

A fresh new App Remote, ready to connect.

Declared In

SPTAppRemote.h

+ frameworkVersion

Determine the current version of the SpotifyAppRemote framework.

+ (NSString *)frameworkVersion

Return Value

The current version of the SpotifyAppRemote framework

Declared In

SPTAppRemote.h

+ spotifyItunesItemIdentifier

The Spotify app iTunes item identifier for use with SKStoreProductViewController for installing Spotify from the App Store.

+ (NSNumber *)spotifyItunesItemIdentifier

Return Value

An NSNumber representing the Spotify iTunes item identifier to be used for the SKStoreProductParameterITunesItemIdentifier key

Declared In

SPTAppRemote.h

  connectionParameters

The parameters to use during connection.

@property (nonatomic, strong, readonly) SPTAppRemoteConnectionParams *connectionParameters

Declared In

SPTAppRemote.h

  connected

YES if the App Remote is connected to the Spotify application, otherwise NO.

@property (nonatomic, assign, readonly, getter=isConnected) BOOL connected

Discussion

Note: Not KVO’able.

See The SPTAppRemoteDelegate in order to receive updates when the connection status changes.

Declared In

SPTAppRemote.h

  delegate

The delegate to notify for connection status changes and other events originating from the App Remote.

@property (nonatomic, weak) id<SPTAppRemoteDelegate> delegate

Declared In

SPTAppRemote.h

– connect

Attempts to connect to the Spotify application.

- (void)connect

Discussion

If the Spotify app is not running the App Remote will try to wake it up.

Declared In

SPTAppRemote.h

– disconnect

Disconnect from the Spotify application

- (void)disconnect

Declared In

SPTAppRemote.h

– authorizeAndPlayURI:

Open Spotify app to obtain access token and start playback.

- (BOOL)authorizeAndPlayURI:(NSString *)URI

Parameters

URI

The URI to play. Use a blank string to attempt to play the user’s last song

Return Value

YES if the Spotify app is installed and an authorization attempt can be made, otherwise NO. Note: The return BOOL here is not a measure of whether or not authentication succeeded, only a check if the Spotify app is installed and can attempt to handle the authorization request.

Declared In

SPTAppRemote.h

– authorizationParametersFromURL:

Parse out an access token or error description from a url passed to application:openURL:options:

- (nullable NSDictionary<NSString*,NSString*> *)authorizationParametersFromURL:(NSURL *)url

Parameters

url

The URL returned from the Spotify app after calling authorizeAndPlayURI

Return Value

A dictionary containing the access token or error description from the provided URL. Will return nil if the URL Scheme does not match the redirect URI provided. Use SPTAppRemoteAccessTokenKey and SPTAppRemoteErrorDescriptionKey to get the appropriate values.

Declared In

SPTAppRemote.h

  playerAPI

The API used to control the Spotify player.

@property (nullable, nonatomic, strong, readonly) id<SPTAppRemotePlayerAPI> playerAPI

Discussion

Note: Will only be populated when the App Remote is connected. If you retain this object you must release it on disconnect.

Declared In

SPTAppRemote.h

  imageAPI

The API used to fetch images from the Spotify app.

@property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteImageAPI> imageAPI

Discussion

Note: Will only be populated when the App Remote is connected. If you retain this object you must release it on disconnect.

Declared In

SPTAppRemote.h

  userAPI

The API used to fetch user data from the Spotify app.

@property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteUserAPI> userAPI

Discussion

Note: Will only be populated when the App Remote is connected. If you retain this object you must release it on disconnect.

Declared In

SPTAppRemote.h

  contentAPI

The API used to fetch content from the Spotify app.

@property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteContentAPI> contentAPI

Discussion

Note: Will only be populated when the App Remote is connected. If you retain this object you must release it on disconnect.

Declared In

SPTAppRemote.h