Giter Club home page Giter Club logo

react-native-spotify's Introduction

Spotify for React Native

A react native module for the Spotify SDK

NOTE: This repo is using the deprecated Spotify streaming SDKs. I have been told by users that it is now no longer functional, since Spotify has turned off the API.

react-native-spotify-remote is being worked on by cjam to use the newer "remote" SDK.

Install

To add the Spotify SDK to your project, cd into your project directory and run the following commands:

npm install --save rn-spotify-sdk
react-native link react-native-events
react-native link rn-spotify-sdk

Next, do the manual setup for each platform:

iOS

Manually add SpotifyMetadata.framework and SpotifyAudioPlayback.framework from node_modules/rn-spotify-sdk/ios/external/SpotifySDK to Linked Frameworks and Libraries in your project settings. Then add ../node_modules/rn-spotify-sdk/ios/external/SpotifySDK to Framework Search Paths in your project settings.

Android

Edit android/build.gradle and add flatDir

...
allprojects {
	repositories {
		mavenLocal()
		jcenter()
		maven {
			// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
			url "$rootDir/../node_modules/react-native/android"
		}
		flatDir {
			dirs project(':rn-spotify-sdk').file('libs'), 'libs'
		}
	}
}
...

Edit android/app/build.gradle and add packagingOptions

...
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
packagingOptions {
    pickFirst 'lib/armeabi-v7a/libgnustl_shared.so'
    pickFirst 'lib/x86/libgnustl_shared.so'
    exclude 'lib/arm64-v8a/libgnustl_shared.so'
    exclude 'lib/x86_64/libgnustl_shared.so'
}
...

In some cases, the two exclude lines cause issues when compiling and can be omitted. I need to look further into what causes this.

On Android, react-native link has a bug where it imports RNSpotifyPackage using the wrong bundle. You may have to make the following change to MainApplication.java:

...
import com.spotify.sdk.android.authentication.RNSpotifyPackage; // remove this line
import com.lufinkey.react.spotify.RNSpotifyPackage; // replace with this line
...

If you have issues linking the module, please check that gradle is updated to the latest version and that your project is synced. Please reference the example app to ensure you've implemented things correctly before opening any issues.

Usage

import Spotify from 'rn-spotify-sdk';

Types

  • Session

    Contains information about a session

    • Properties

      • accessToken - A token used to communicate with the Spotify API
      • expireTime - The time that the access token expires, in milliseconds from January 1, 1970 00:00:00 UTC
      • refreshToken - An encrypted token used to get a new access token when they expire. This should be encrypted by your token swap service, as per OAuth standards.
      • scopes - An array of scopes that the session has access to. A list of scopes can be found here.
  • PlaybackState

    Contains information about the current state of the player

    • Properties

      • playing - boolean indicating whether the player is playing
      • repeating - boolean indicating whether the player is repeating
      • shuffling - boolean indicating whether the player is shuffling
      • activeDevice - boolean indicating whether the current device is the one playing
      • position - the position of the player in the current track, in seconds
  • PlaybackTrack

    Contains information about a track in the playback queue

    • Properties

      • name - The title of the track
      • uri - The uri of the track
      • contextName - The name of the playlist or album that the track is being played from
      • contextUri - The uri of the playlist or album that the track is being played from
      • artistName - The name of the track's artist
      • artistUri - The uri of the track's artist
      • albumName - The name of the album that the track belongs to
      • albumUri - The uri of the album that the track belongs to
      • albumCoverArtURL - A URL for the album art image
      • duration - The length of the track in seconds
      • indexInContext - The track index in the playlist or album that the track is being played from
  • PlaybackMetadata

    Contains information about the previous, current, and next tracks in the player

    • Properties

      • prevTrack - A PlaybackTrack with information about the previous track
      • currentTrack - A PlaybackTrack with information about the current track
      • nextTrack - A PlaybackTrack with information about the next track
  • PlaybackEvent

    Contains information about a playback event and the state of the player.

    • Properties

      • state - the player's current PlaybackState
      • metadata - the player's current PlaybackMetadata

Events

This module uses react-native-events, so it has all of the same methods as an EventEmitter object. All of the events except for 'disconnect' / 'reconnect' (on Android) and 'login' / 'logout' come from Spotify's native SDK and are simply forwarded to javascript. If one of these events occurs at a weird time or has strange data, please open an issue on Spotify's ios-streaming-sdk or android-streaming-sdk repo, and not here.

  • 'login'

    • session {Session}

    Emitted when the module has successfully logged in.

  • 'logout'

    Emitted when the module is logged out.

  • 'sessionRenewed'

    • session {Session}

    Emitted when the session has been renewed.

  • 'play'

    • event {PlaybackEvent}

    Emitted when playback has started or has resumed.

  • 'pause'

    • event {PlaybackEvent}

    Emitted when playback is paused.

  • 'trackChange'

    • event {PlaybackEvent}

    Emitted when playback of a new/different track starts.

  • 'metadataChange'

    • event {PlaybackEvent}

    Emitted when metadata has changed. This event occurs when playback starts or changes to a different context, when a track switch occurs, etc. This is an informational event that does not require action, but should be used to keep the UI display updated with the latest metadata information.

  • 'contextChange'

    • event {PlaybackEvent}

    Emitted when playback starts or changes to a different context than was playing before, such as a change in album or playlist.

  • 'shuffleStatusChange'

    • event {PlaybackEvent}

    Emitted when "shuffle" is switched on or off.

  • 'repeatStatusChange'

    • event {PlaybackEvent}

    Emitted when "repeat" is switched on or off.

  • 'active'

    • event {PlaybackEvent}

    Emitted when this device has become the active playback device. This event occurs when the users moves playback to this device using Spotify Connect.

  • 'inactive'

    • event {PlaybackEvent}

    Emitted when this device is no longer the active playback device. This event occurs when the user moves playback to a different device using Spotify Connect.

  • 'permissionLost'

    • event {PlaybackEvent}

    Emitted when this device has temporarily lost permission to stream audio from Spotify. A user can only stream audio on one of her devices at any given time. If playback is started on a different device, this event may occur.

  • 'audioFlush'

    • event {PlaybackEvent}

    Emitted when the application should flush its audio buffers (you don't need to deal with this since that's handled by the native code). For example, this event occurs when seeking to a different position within a track.

  • 'audioDeliveryDone'

    • event {PlaybackEvent}

    Emitted when the library reaches the end of a playback context and has no more audio to deliver.

  • 'trackDelivered'

    • event {PlaybackEvent}

    Emitted when the application accepted all samples from the current track. This is an informative event that indicates that all samples from the current track have been delivered to and accepted by the application. The track has not yet finished playing the last audio sample, but no more audio will be delivered for this track. For nearly all intents and purposes, the track has finished playing.

  • 'disconnect'

    Emitted when the player loses network connectivity.

  • 'reconnect'

    Emitted when the player regains network connectivity.

  • 'temporaryPlayerError'

    Emitted when service has been interrupted, usually by lack of network access. However, it can also occur if there is a problem with Spotify's backend services, or also when the user switches from WiFi to 3G. These errors can occur in many non-critical situations, and thus it is not necessary to show toasts or alert dialogs when receiving this event, or else you will unnecessarily annoy or panic the user. However, it can be useful to know about these events if operations are consistently failing, in which case showing a toast or alert may be justified.

  • 'playerMessage'

    • message {String}

    Called when the player has recieved a message for the end user from the Spotify service.

Initialization/Authorization Methods

  • initialize( options )

    Initializes the Spotify module and resumes a logged in session if there is one. This must be the first method you call when using this module.

    • Parameters

      • options - an object with options to pass to the Spotify Module
        • clientID - (Required) Your spotify application's client ID that you registered with spotify here
        • redirectURL - (Required) The redirect URL to use when you've finished logging in. You NEED to set this URL for your application here, otherwise the login screen will not close
        • sessionUserDefaultsKey - The preference key to use in order to store session data for this module. Set this to a string of your choice when you initialize in order to persist user information between app uses.
        • scopes - An array of scopes that define permissions for the Spotify API. A list of scopes can be found here
        • tokenSwapURL - The URL to use to swap an authentication code for an access token (see Token swap and refresh section for more info)
        • tokenRefreshURL - The URL to use to get a new access token from a refresh token
        • tokenRefreshEarliness - The number of seconds to set a token refresh timer before the access token expires. Default is 300
        • ios - iOS specific options
          • audioSessionCategory - The name of the audio session category to use for playing music in the app. Default is 'AVAudioSessionCategoryPlayback'
        • android - Android specific options
          • loginLoadingText - The "Loading" text that will show on the login popup
    • Returns

      • A Promise that resolves to a boolean when the module finishes initialization, indicating whether or not a session was automatically logged back in
  • isInitialized()

    Checks if the Spotify module has been initialized yet.

    • Returns

      • true if the Spotify module has been initialized
      • false if the Spotify module has not been initialized
  • isInitializedAsync()

    Checks if the Spotify module has been initialized yet, but returns a Promise that resolves to the result.

    • Returns

      • A Promise that resolves to a boolean, indicating whether or not the Spotify module has been initialized
  • login( options? )

    Opens a UI to log into Spotify.

    • Parameters

      • options
        • showDialog - Whether or not to force the user to approve the app again if they’ve already done so.
        • clientID - Your spotify application's client ID that you registered with spotify here. Falls back to value given in initialize.
        • redirectURL - The redirect URL to use when you've finished logging in. You NEED to set this URL for your application here, otherwise the login screen will not close. Falls back to value given in initialize.
        • scopes - An array of scopes that define permissions for the Spotify API. A list of scopes can be found here. Falls back to value given in initialize.
        • tokenSwapURL - The URL to use to swap an authentication code for an access token (see Token swap and refresh section for more info). Falls back to value given in initialize.
    • Returns

      • A Promise that resolves to a boolean, indicating whether or not the user was logged in
  • isLoggedIn()

    Checks if the client is logged in.

    • Returns

      • true if the client is logged in
      • false if the client is not logged in
  • isLoggedInAsync()

    Checks if the client is logged in, but returns a Promise that resolves to the result.

    • Returns

      • A Promise that resolves to a boolean, indicating whether or not a user is currently logged in
  • logout()

    Logs out of Spotify.

    • Returns

      • A Promise that resolves when the logout completes
  • getSession()

    Gives information about the current session.

    • Returns

      • An Session object, or null if not logged in
  • getSessionAsync()

    Gives information about the current session, but returns a Promise that resolves to the result.

    • Returns

      • A Promise that resolves to an Session object, or null if not logged in
  • renewSession()

    Renews a logged in session. If no token refresh URL was given to initialize or if the session does not have a refresh token, this function returns without error

    • Returns

      • A Promise that resolves when the session renewal attempt finishes
  • authenticate( options? )

    Opens a UI to perform the auth flow for Spotify, but returns a session instead of logging in.

    • Parameters

      • options
        • showDialog - Whether or not to force the user to approve the app again if they’ve already done so.
        • clientID - Your spotify application's client ID that you registered with spotify here. Falls back to value given in initialize.
        • redirectURL - The redirect URL to use when you've finished logging in. You NEED to set this URL for your application here, otherwise the login screen will not close. Falls back to value given in initialize.
        • scopes - An array of scopes that define permissions for the Spotify API. A list of scopes can be found here. Falls back to value given in initialize.
        • tokenSwapURL - The URL to use to swap an authentication code for an access token (see Token swap and refresh section for more info). Falls back to value given in initialize.
    • Returns

      • A Promise that resolves to an Session object, or null if login is cancelled
  • loginWithSession( options )

    Logs into the app with a given session

    • Parameters

      • options
        • accessToken (Required) - The token to use to communicate with the Spotify API.
        • expireTime (Required) - The time that the access token expires, in milliseconds from January 1, 1970 00:00:00 UTC
        • refreshToken - An encrypted token used to get a new access token when it expires.
        • scopes - An array of scopes that the session has access to. A list of scopes can be found here.
        • clientID - Your spotify application's client ID that you registered with spotify here. Falls back to value given in initialize.
        • tokenRefreshURL - The URL to use to get a new access token from a refresh token (see Token swap and refresh section for more info). Falls back to value given in initialize.
    • Returns

      • A Promise that resolves when the login finishes

Playback Methods

  • playURI( spotifyURI, startIndex, startPosition )

    Play a Spotify URI.

    • Parameters

      • spotifyURI - The Spotify URI to play
      • startIndex - The index of an item that should be played first, e.g. 0 - for the very first track in the playlist or a single track
      • startPosition - starting position for playback in seconds
    • Returns

      • A Promise that resolves or rejects when the operation is complete
  • queueURI( spotifyURI )

    Queue a Spotify URI. WARNING: This function has proven to be very inconsistent and buggy.

    • Parameters

      • spotifyURI - The Spotify URI to queue
    • Returns

      • A Promise that resolves or rejects when the operation is complete
  • setPlaying( playing )

    Set the “playing” status of the player.

    • Parameters

      • playing - true to resume playback, or false to pause it
    • Returns

      • A Promise that resolves or rejects when the operation is complete
  • getPlaybackState()

    Gives the player's current state.

    • Returns

      • A PlaybackState object, or null if the player has not yet initialized
  • getPlaybackStateAsync()

    Gives the player's current state, but returns a Promise that resolves to the result.

    • Returns

      • A Promise that resolves to a PlaybackState object or null if the player has not yet initialized
  • getPlaybackMetadata()

    Gives information about the previous, current, and next track in the player.

    • Returns

      • A PlaybackMetadata object, or null if the player has yet initialized
  • getPlaybackMetadataAsync()

    Gives information about the previous, current, and next track in the player, but returns a Promise that resolves to the result.

    • Returns

      • A Promise that resolves to a PlaybackMetadata object or null if the player has not yet initialized
  • skipToNext()

    Skips to the next track.

    • Returns

      • A Promise that resolves or rejects when the operation is complete
  • skipToPrevious()

    Skips to the previous track.

    • Returns

      • A Promise that resolves or rejects when the operation is complete
  • seek( position )

    Seeks to a position within the current track

    • Parameters

      • position - The position in seconds to seek to
    • Returns

      • A Promise that resolves or rejects when the operation is complete
  • setShuffling( shuffling )

    Enables or disables shuffling on the player.

    • Parameters

      • shuffling - true to enable shuffle, false to disable it
    • Returns

      • A Promise that resolves or rejects when the operation is complete
  • setRepeating( repeating )

    Enables or disables repeating on the player.

    • Parameters

      • repeating - true to enable repeat, false to disable it
    • Returns

      • A Promise that resolves or rejects when the operation is complete

Metadata Methods

  • sendRequest( endpoint, method, params, isJSONBody )

    Sends a general request to the spotify api. A list of potential endpoints can be found here.

    • Parameters

      • endpoint - the api endpoint, without a leading slash, e.g. 'v1/browse/new-releases'
      • method - the HTTP method to use
      • params - the request parameters
      • isJSONBody - whether or not to send the parameters as json in the body of the request
    • Returns

      • A Promise that resolves to the result of the API request
  • getMe()

    Retrieves information about the logged in Spotify user.

    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • search( query, types, options? )

    Sends a search request to spotify.

    • Parameters

      • query - The search query string. Same as the q parameter on the search endpoint
      • types - An array of item types to search for. Valid types are: 'album', 'artist', 'playlist', and 'track'.
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the search result object. An example response can be seen here
  • getAlbum( albumID, options? )

    Gets Spotify catalog information for a single album.

    • Parameters

      • albumID - The Spotify ID for the album
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getAlbums( albumIDs, options? )

    Gets Spotify catalog information for multiple albums identified by their Spotify IDs.

    • Parameters

      • albumIDs - An array of the Spotify IDs for the albums
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getAlbumTracks( albumID, options? )

    Gets Spotify catalog information about an album’s tracks.

    • Parameters

      • albumID - The Spotify ID for the album
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getArtist( artistID, options? )

    Gets Spotify catalog information for a single artist.

    • Parameters

      • artistID - The Spotify ID for the artist
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getArtists( artistIDs, options? )

    Gets Spotify catalog information for several artists based on their Spotify IDs.

    • Parameters

      • artistIDs - An array of the Spotify IDs for the artists
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getArtistAlbums( artistID, options? )

    Gets Spotify catalog information about an artist’s albums.

    • Parameters

      • artistID - The Spotify ID for the artist
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getArtistTopTracks( artistID, country, options? )

    Gets Spotify catalog information about an artist’s top tracks by country.

    • Parameters

      • artistID - The Spotify ID for the artist
      • country - The country: an ISO 3166-1 alpha-2 country code.
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getArtistRelatedArtists( artistID, options? )

    Gets Spotify catalog information about artists similar to a given artist.

    • Parameters

      • artistID - The Spotify ID for the artist
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getTrack( trackID, options? )

    Gets Spotify catalog information for a single track identified by its unique Spotify ID.

    • Parameters

      • trackID - The Spotify ID for the track
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getTracks( trackIDs, options? )

    Gets Spotify catalog information for multiple tracks based on their Spotify IDs.

    • Parameters

      • trackIDs - An array of the Spotify IDs for the tracks
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getTrackAudioAnalysis( trackID, options? )

    Gets a detailed audio analysis for a single track identified by its unique Spotify ID.

    • Parameters

      • trackID - The Spotify ID for the track
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getTrackAudioFeatures( trackID, options? )

    Gets audio feature information for a single track identified by its unique Spotify ID.

    • Parameters

      • trackID - The Spotify ID for the track
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here
  • getTracksAudioFeatures( trackIDs, options? )

    Gets audio features for multiple tracks based on their Spotify IDs.

    • Parameters

      • trackIDs - An array of the Spotify IDs for the tracks
      • options - A map of other optional parameters to specify for the query
    • Returns

      • A Promise that resolves to the request result object. An example response can be seen here

Token swap and refresh

In order for your app to stay logged into Spotify for more than an hour, you must set up your own server with endpoints for token swap and refresh, and specify your tokenSwapURL and tokenRefreshURL parameters in the Spotify.initialize method

The tokenSwapURL parameter is used to swap the authentication code provided by the Spotify login process for an access token and a refresh token.

The tokenRefreshURL parameter is used to retrieve new access tokens for the user using the refresh token received from the tokenSwapURL.

Both URLs are queried using POST with a Content-Type of application/x-www-form-urlencoded.

You can find an example server implementation here.

Refresh tokens are part of OAuth standard. If you are not familiar with them, Understanding Refresh Tokens can give you a basic idea on how they work.

Additional notes

This module only works for Spotify Premium users.

react-native-spotify's People

Contributors

0duaht avatar adebree avatar bdilly avatar buraktt avatar dcvz avatar dependabot[bot] avatar grabbou avatar linuxboss182 avatar lufinkey avatar robertoost avatar yamalight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-spotify's Issues

Error compiling: method toHashMap() does not exist on ReadableMap class

Please help
Error when run: react-native run-android
Using: React-native version 0.45.1

.../node_modules/@lufinkey/react-native-spotify/android/src/main/java/com/lufinkey/react/spotify/Utils.java:24: error: cannot find symbol HashMap<String, Object> map = params.toHashMap(); ^ symbol: method toHashMap() location: variable params of type ReadableMap 1 error :react-native-spotify:compileReleaseJavaWithJavac FAILED

Cannot read property 'string' of undefined

I am facing error after installing latest "react-native-spotify"

Error: Cannot read property 'string' of undefined

I didnt imported plugin yet but just installed and run fails...

How To Produce

  1. npm install --save react-native-spotify
  2. react-native link
  3. react-native run-ios

Comes with Error

  • simulator

simulator

  • React Native debugger

consolelog

Environments

  • Package.json

packagejson

  • React Native Info

reactnativeinfo

Notes

  • Tried all different things to install package like
    npm install --save https://github.com/lufinkey/react-native-spotify
    npm install --save @lufinkey/react-native-spotify
    npm install --save react-native-spotify
  • Tried deleting node_modules and install it again
  • Tried auto-link and manual-link as given on documentation

Help me out of this issue as soon as possible.
Thanks.

Module does not exist in the module map

I just updated my modules and now it says that it cannot find 'react-native-spotify'. I've run all of the suggested commands for clearing cache and all but nothing seems to have worked. Is this happening to just me?

Undefined symbols for architecture

I just updated my module from the old module (react-native-spotify) to the new module (rn-spotify-sdk), but now this error is being thrown and is preventing it from building.

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RNEventEmitter", referenced from:
      objc-class-ref in libRNSpotify.a(RNSpotify.o)

Where is this coming from? I followed all of the steps on the README page and this is what occurred. Has anyone else seen this issue?

Android example not working: Could not communicate with server error#105

I tried to run your example project on android, configured a spotify app on the developer platform (clientID, callback urls, package name and sha1 fingerprint) and got as far as the spotify login screen/dialogue in the example. After pressing the okay button (with correct login credentials) the dialogue closes.

		Spotify.login((loggedIn, error) => {
			if(error)
			{
                                // The code ends up here with this error log.
				console.log('Error logging in: ', error);
				Alert.alert("Error", error.message);
			}
                        ...
		});

which results in this error log:

{code: 105, message: "Could not communicate with server", domain: "RCTSpotifyErrorDomain"}

What is failing here? How can I run the example project in android successfully?

Not linking correctly and other issues

Thanks for sharing your project, I'd love to use this in my project but I've had a rough time getting it working (ios).

  1. react-native link command wasn't linking for me. I had to manually link the project. I'm not sure why.

  2. Once linked it failed to build for me w/ an error at RCTSpotifyConvert.m line 21. I'm not sure if this is an artifact from your testing/debugging. Once I commented it out the project began to compile and I could see the native module loading on the JS side.

I continue to work my way through issues.

It would be incredibly useful to have a simple example of a one file working example for IOS and Android.

Include in README that this is only for premium users

Hi,

The login() method return always false.
I do the login inside the webview and when I come back on app the boolean "loggedIn" is false.

I tried it on iOS Simulator 9.3, and a free Spotify account.

I do not know where to start to understand the reason for this problem.

Caching for web requests

In the initialization options, you should be able to set a cache size and expiration for web requests, to prevent Spotify's API usage rates from kicking in

Add iOS / Android specific options to README

So I'm using react-native-music-control to add control center / lockscreen controls to my app, but there's a limitation in iOS where MPNowPlayingInfoCenter only shows the controls on a real device if it has a non mixable audio session category.

Digging around in this module's native code I found in RCTSpotify.m line 200 the following:

_audioSessionCategory = iosOptions[@"audioSessionCategory"];
if(_audioSessionCategory == nil)
{
	_audioSessionCategory = AVAudioSessionCategoryPlayback;
}

My question is, what audio session category is it using and can this be changed without other effects in the app? Forcing it to use AVAudioSessionCategoryPlayback allows the control center and lockscreen controls to work perfectly fine, I just want to know if there's a reason this is here.

Thanks in advance.

Cannot add new playlist via sendRequest

I am trying to add a new playlist to my Spotify via the sendRequest method.

This is my code:

Spotify.sendRequest(
    `https:\/\/api.spotify.com\/v1\/users\/${this.props.spotifyId}\/playlists`,
    'POST',
    {
        name: 'test'
    },
    true,
    (result, error) => {
          if (error) {
              console.log(error);
          } else {
              console.log(result);
          }
    }
);

But this is the error I get back:

{message: "Service not listed", domain: "com.spotify.web-api", code: 404}

Anyone able to do this successfully?

Issue with getAuth and getAuthAsync

Hi,

Thanks for updating the library but when I use getAuth or getAuthAsync this error appears:

Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]' was thrown while invoking getAuthAsync on target Spotify with params (
199
)

callstack: (
0 CoreFoundation 0x000000010525012b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001036fdf41 objc_exception_throw + 48
2 CoreFoundation 0x00000001052900cc _CFThrowFormattedException + 194
3 CoreFoundation 0x0000000105164951 -[_NSPlaceholderDictionary initWithObjects:forKeys:count:] + 321
4 CoreFoundation 0x00000001051647db +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
5 spotifyAPI 0x0000000102b226b7 +[RCTSpotifyConvert SPTAuth:] + 487
6 spotifyAPI 0x0000000102b28078 -[RCTSpotify getAuth] + 56
7 spotifyAPI 0x0000000102b2810a -[RCTSpotify getAuthAsync:] + 106
8 CoreFoundation 0x00000001051d436c invoking
+ 140
9 CoreFoundation 0x00000001051d4240 -[NSInvocation invoke] + 320
10 CoreFoundation 0x00000001051ecc26 -[NSInvocation invokeWithTarget:] + 54
11 spotifyAPI 0x00000001028e794c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2796
12 spotifyAPI 0x00000001029972e2 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 786
13 spotifyAPI 0x0000000102996e0f _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127
14 spotifyAPI 0x0000000102996d89 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
15 libdispatch.dylib 0x0000000109af7177 _dispatch_call_block_and_release + 12
16 libdispatch.dylib 0x0000000109af81ba _dispatch_client_callout + 8
17 libdispatch.dylib 0x0000000109affd3d _dispatch_queue_serial_drain + 654
18 libdispatch.dylib 0x0000000109b005a0 _dispatch_queue_invoke + 329
19 libdispatch.dylib 0x0000000109afcc97 _dispatch_queue_override_invoke + 477
20 libdispatch.dylib 0x0000000109b02980 _dispatch_root_queue_drain + 568
21 libdispatch.dylib 0x0000000109b026ea _dispatch_worker_thread3 + 119
22 libsystem_pthread.dylib 0x0000000109fb75a2 _pthread_wqthread + 1299
23 libsystem_pthread.dylib 0x0000000109fb707d start_wqthread + 13
)

I use ios emulator.

Thanks.

Does Premium account required?

Can user without premium account use that lib? Or I can't use all api methods of spotify with free account.
error:

{
"code":93,
"message":"kSpErrorNeedsPremium",
"domain":"RCTSpotifyErrorDomain"
}

npmjs published library not working, missing ios-sdk

Problem becomes apparent when following the installation instruction until:

Manually add the Frameworks from node_modules/@lufinkey/react-native-spotify/ios/external/SpotifySDK...

There is no external directory, so nothing to install:

image

Trying to build the app without this step fails (of course) with: 'SpotifyAuthentication/SpotifyAuthentication.h' file not found

I've validated this with a fresh React Native app:

  • Generated an app with react-native init rns
  • cd rns
  • npm install --save @lufinkey/react-native-spotify
  • react-native link @lufinkey/react-native-spotify

No external in this directory:

$ ls node_modules/@lufinkey/react-native-spotify/ios/
HelperMacros.h             RCTSpotify.m               RCTSpotify.xcworkspace     RCTSpotifyConvert.m        SpotifyWebViewController.m
RCTSpotify.h               RCTSpotify.xcodeproj       RCTSpotifyConvert.h        SpotifyWebViewController.h

Playback error callback not called if streaming scope is missing

For some reason Spotify.playURI does not work in my code. The client is successfully initialized and logged in.

When I call:

Spotify.playURI("spotify:track:5wq3CjLmwgWnH5Z8IYqhCJ", 0, 0, err => {
      console.log(err);
      console.log(Spotify.getPlaybackState());
});

it won't play the track and the callback is never called -> there is no output in the console. Any ideas what could be the reason?

I have also linked AVFoundation.framework and RN is 0.53.3

Cannot get local player context

The situation

I've been using sendRequest to get the current context that the player is streaming in. The "context", in this case, is the playlist, album, track, or list of tracks currently being played. The endpoint I'm sending GET requests to is v1/me/player. (Get Information About The User’s Current Playback)

The context object that I expect to receive:
player.context

"context": {
    "external_urls" : {
      "spotify" : "http://open.spotify.com/user/spotify/playlist/49znshcYJROspEqBoHg3Sv"
    },
    "href" : "https://api.spotify.com/v1/users/spotify/playlists/49znshcYJROspEqBoHg3Sv",
    "type" : "playlist",
    "uri" : "spotify:user:spotify:playlist:49znshcYJROspEqBoHg3Sv"
  }

The problem

I want to know what context I'm in and if it matches the context that the player is supposed to be playing in. So far, I've been successfully controlling my other devices with Spotify Connect. When I have a session on a different device going on, I can get the current context just fine. It's when I start playback on the local player that everything falls apart.

Sending a GET request to v1/me/player while a local session is active produces an empty result. This makes me think that the local player context should gettable somewhere in the Android and iOS SDKs, although, I'm not so sure about all that. Is this possible locally?

Update README to explain OAuth server and how to use it

I'm trying to setup a simple server to have refreshable tokens. I've setup my own server and configured it as required, executing requests manually produces correct tokens.
I've configured react-native-spotify the following way:

const spotifyOptions = {
  clientID: 'my-id',
  sessionUserDefaultsKey: 'SpotifySession',
  redirectURL: 'myapp://auth',
  tokenSwapURL: 'https://my.url/swap',
  tokenRefreshURL: 'https://my.url/refresh',
  scopes: ['user-read-private', 'playlist-read', 'playlist-read-private', 'streaming'],
};
Spotify.initialize(spotifyOptions, (loggedIn, error) => {
  // ...
});

But all I currently get is an error "Missing expected response parameters" with following app crash.
What's stranger - the server doesn't get any incoming requests at all.
Any idea why that might happen? Am I missing something in my config?

Error linking the sdk on the android platform

Hello,

when adding the flatDir { url "$rootDir/../node_modules/react-native-spotify/android/libs" } to the build.gradle, i got this error Gradle DSL method not found 'google()'.
Do you have any idea what do i need to to to fix this? This is because my grade version doesnt support this yet. (Its a brand new react-native project).

Invariant Violation: Calling synchronous methods on native modules is not supported in Chrome.

Hi,

The problem occurs when I enable debug mode with chrome, this error appears:

_Invariant Violation: Calling synchronous methods on native modules is not supported in Chrome.

Consider providing alternative methods to expose this method in debug mode, e.g. by exposing constants ahead-of-time.

This error is located at:
in App (at renderApplication.js:35)
in RCTView (at View.js:71)
in View (at AppContainer.js:102)
in RCTView (at View.js:71)
in View (at AppContainer.js:122)
in AppContainer (at renderApplication.js:34)_

When I stop the debug mode the error disappears.
I'm doing the library test with the ios emulator

Thanks.

Dialogs

Hello again,

Is there any way to make optional or able to customize the dialogs from commit 0ae99a6?

I'd like to keep my app as clean as possible.

Thank you so much.

Setting up refresh/swap token server

Hi!

So I set up my own server with its own url using the server implementation example as a template. When I however use this url+/refresh and url+/swap for tokenRefreshURL and tokenSwapURL props for the options body it doesn't even initialize. Trying to catch the error, this is all I'm getting:

03-22 21:35:47.184 6926 7380 W ReactNativeJS: Possible Unhandled Promise Rejection (id: 0):
03-22 21:35:47.184 6926 7380 W ReactNativeJS: Error: Unable to send request

Any help is appreciated,

Thank you!

getAuthAsync resolves by returning an array

getAuth returns an object, but getAuthAsync returns an array containing the object.

It's not really an issue, but it would be coherent to have both method resolve the same way. I don't think there are other methods returning an array like this, so that might be a mistake.

Thanks for that great lib!

Spotify SDK 'loginWithAccessToken' method

Hi, thanks for a fantastic library!

Our users have already authorized via the web and therefore our server is able to generate valid access tokens without additional user interaction.

Would it be possible to skip the user auth/login process and initialize Spotify SDK playback with a valid access token provided by our server?

I noticed that the Spotify SDK SPTAudioStreamingController class exports a loginWithAccessToken method which may do just that: https://spotify.github.io/ios-sdk/Classes/SPTAudioStreamingController.html#//api/name/loginWithAccessToken:

Is this something that can be enabled/exposed in your library?

Change README to use Linked Frameworks instead of Embedded Binaries

Ran in an unfortunate problem while exporting an app with @lufinkey/react-native-spotify installed.

Shortest steps to reproduce:

  • Create an empty / new react-native project react-native init spotifytest
  • cd spotifytest
  • Go through the installation steps of @lufinkey/react-native-spotify:
  • npm install --save @lufinkey/react-native-spotify
  • react-native link @lufinkey/react-native-spotify
  • Manually add the Frameworks from node_modules/@lufinkey/react-native-spotify/ios/external/SpotifySDK to Embedded Binaries in your project settings.
  • Then add ../node_modules/@lufinkey/react-native-spotify/ios/external/SpotifySDK to Framework Search Paths in your project settings.
  • Select in XCode a development team and make sure the app is signable
  • Select XCode menu Product => Archive
  • After successful build / archive go in XCode menu to Window => Organizer
  • Select in the dialog the Archive that just has been made and press the 'Export' button:
    image
  • Select 'App Store' option as method of Distribution and press next:
    image

We are encountering this issue on both local XCode and Bitrise while making exports. This error is not given when exporting before installing the @lufinkey/react-native-spotify package. I am still investigating if there is more information available.

> Error: more than one library with package name 'com.lufinkey.react.spotify'

In the instructions on how to install react-native-spotify through npm, you mention having to replace "@lufinkey/react-native-spotify" with "@lufinkey_react-native-spotify" in several .gradle files. This works during initial setup, but after linking the project again, and running npm i, my project broke down.

> Error: more than one library with package name 'com.lufinkey.react.spotify'

It seems the replaced versions of the string have been raised from the dead to haunt me, as both versions of the string are now present in my .gradle files.

    compile project(':@lufinkey/react-native-spotify')
    compile project(':@lufinkey_react-native-spotify')
include ':@lufinkey/react-native-spotify'
project(':@lufinkey/react-native-spotify').projectDir = new File(rootProject.projectDir, '../node_modules/@lufinkey/react-native-spotify/android')
include ':@lufinkey_react-native-spotify'
project(':@lufinkey_react-native-spotify').projectDir = new File(rootProject.projectDir, '../node_modules/@lufinkey/react-native-spotify/android')

Removing the lines that use a "/" does allow the project to start on android, but it fails immediately ( as shown in the image below ).
I have the feeling that this has something to do with this double module issue. Any thoughts on how to fix this?

See Image here

image

getArtistTopTracks doesn't work

Thats not my issue on IOS. I demonstrated the call I make and it still gives there error specified.

The second argument should just be a string, the third argument can be null or an object with >>optional parameters (currently there aren't any other optional parameters for this method though),
Thats what I am doing no?

Spotify.getArtistTopTracks(spotifyId,'US',null, (popular, error) => {

This returns missing country? When I fix the objective-c code myself it works. ???

	NSString* endpoint = NSString_concat(@"v1/artists/", artistID, @"/top-tracks");
	[self doAPIRequest:endpoint method:@"GET" params:options jsonBody:NO completion:^(id resultObj, NSError* error) {
		if(completion)
		{
			completion(@[ [RCTSpotifyConvert ID:resultObj], [RCTSpotifyConvert NSError:error] ]);
		}
	}];

Is there not a bug with params:options? If it can be null?

undefined is not an object

After adding in some new libraries, now my call to this library is apparently not working. I call 'import Spotify from "react-native-spotify"' at the top but when I reach the Spotify object inside my constructor, it is undefined and throws an error. Any ideas?

Android: Newest version doesn't reach the token server. error#105

Something is still wrong here, I updated and changed _GET back to _POST again, but now the app is not reaching the server at all. I added some error logging to the php server at the start of the swap.php and refresh.php files.

error_log( "SERVER REACHED" );
echo "Server reached";

Monitoring these logs during testing revealed some interesting stuff.

Reaching out to the server ip:port/swap.php or refresh.php through the browser does generates logs from the server, but pressing the login button gives me no feedback in my logs, and the app is just stuck in a white screen now. I double checked my Spotify.initialize variables, but they haven't changed since I last updated.

	    "sessionUserDefaultsKey":"SpotifySession",
            "redirectURL":"ritualsspotifydevelop://callback",
            "scopes":["streaming", "user-read-playback-state","user-read-private", "user-modify-playback-state", "playlist-read-private"],
            "tokenSwapURL":"http://{ip address}:{port}/swap.php",
            "tokenRefreshURL":"http://{ip address}:{port}/refresh.php"

When I reverted back to 7de1c8c, the app could reach the server again. I'll remove the _POSTs and stick with the temporary _GET fix for now.

To be clear, I'm logging when the server gets approached in any way, shape or form. The browser triggers logs (SERVER REACHED) and shows the echo (Server reached) in the page, the 7de1c8c version of the app produces the same logs when I press login, it's just the new update that's giving me nothing ( and a blank screen ).

Do you have any idea what could be causing this?

Support iOS SDK 'seekTo' method

I see that the Android implementation exports a seekToPosition function.

Can we get support for the iOS SDK seekTo method?

handleAuthURLAsync needed for remote JS debugging

Thanks Luis for work on this library!

This issue is an extension of #3 (closed). In order to use remote JS debugging, all functions should run asynchronously. handleAuthURL should have an async version like isLoggedInAsync and isInitializedAsync in order for the full authorization cycle to work.

Copied from example file:

App.handleOpenURL = event => {
  // below is the function (handleAuthURL) that chrome doesn't like
  if (Spotify.handleAuthURL(event.url)) {
    return true;
  }
  return false;
};
Linking.addEventListener('url', App.handleOpenURL);

display_name returns null

Hey! I'm trying to work with the example provided on the repo.

I got this output. It looks like my username shows up under id, rather than display_name. Am I making a mistake?

{ product: 'premium', external_urls: { spotify: 'https://open.spotify.com/user/MYUSERNAME' }, followers: { href: null, total: 0 }, country: 'US', images: [], id: 'MYUSERNAME', href: 'https://api.spotify.com/v1/users/MYUSERNAME', display_name: null, type: 'user', uri: 'spotify:user:MYUSERNAME' }

Android: Getting stuck during login. "Cannot call showAuthActivity... " error#100

An issue somewhat related to #4, if the initial login attempt goes wrong, the application cannot retry a login. Those who do try get greeted with a 100 error:

{code: 100, message: "Cannot call showAuthActivity while it is already being called", domain: "RCTSpotifyErrorDomain"}

While this can be prevented by fixing #4, the app does need to be reinstalled if this error is ever encountered. Reloading doesn't seem to work, so my workflow looks like this:

Get a 105 error -> Fix issue in code -> Reload application -> Get a 100 error -> Rerun react-native run-android -> Repeat if fix didn't work.

I find myself having to reinstall the app after every test.
Is this an issue with the Spotify SDK? Or is this something that can be fixed? It's concerning to me that any end-users might have to reinstall the app after their app fails to close the login screen correctly.

Does anyone else recognise the issue? Any tips?

Logout function

Is it possible to logout from the spotify account using your SDK?

iOS build fails with 'too many errors emitted, stopping now'

Hey there! I have followed the installation steps:

  1. npm install --save @lufinkey/react-native-spotify
  2. react-native link @lufinkey/react-native-spotify
  3. Manually add the Frameworks from node_modules/@lufinkey/react-native-spotify/ios/external/SpotifySDK to Embedded Binaries in your project settings.
  4. Then add ../node_modules/@lufinkey/react-native-spotify/ios/external/SpotifySDK to Framework Search Paths in your project settings.

And when I try to build in Xcode I'm getting lots of errors/warnings in RCTSpotify.m

screen shot 2018-03-17 at 11 33 48 am

Any idea what I'm doing wrong? Thanks a lot in advance!

react-native: 0.44.3

Unable to find explicit activity class mypackage/com.lufinkey.react.react.spotify.AuthActivity

I get a red screen when calling Spotify.login(...) in my JS code and I cannot figure out why. I built the example project and it worked fine. I created a new project installed react-native-spotify like described in the readme and it worked fine as well. However when I use it in the project im currently developing I get stuck with the error.

I compared app/buidl.gradle and build.gradle of the example project. All the versions e.g build tools line up. The module itself is linked properly since I import the module just fine, i can even call Spotify.initialize (like in the example project). The react and react-native versions are compatible as well.

So the problem has to do with the fact that login is trying to start the overlay activity which somehow cannot be found the exact error message is: Unable to find explicit activity class mypackage/com.lufinkey.react.react.spotify.AuthActivity; have you declared this activity in your AndroidManifest.xml?

My AndroidManifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
    package="com.votemmusic"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.VIBRATE"/>

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="22" />

    <application
      android:name=".MainApplication"
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme"
      tools:node="replace">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

Other infos:
My Application:
compileSdkVersion 23
buildToolsVersion "23.0.2"
classpath 'com.android.tools.build:gradle:2.2.3' ( I created a project with this gradle version and it worked)
"react": "16.0.0"
"react-native": "0.50.4"

Any recommendations what I should do to get this to work? Is this a conflict with other dependencies? I have tried to add the activity to my AndroidManifest but this just leads to a total crash of the app.
Thanks in advance!

Does not play songs added to playlist after calling playURI

I have my code such that I can create a new playlist on Spotify and add songs to it. However, I add my songs to the playlist and call playURI on the playlist ID, but when I go to add new songs to the existing playlist, the playURI stops playing the songs as soon as it reaches the end of the first list of songs I queued up before calling playURI. For example, if I queue song1 and song2 to the playlist, call playURI on the playlist ID, and then add song3 to the playlist while it is playing, the playlist only plays through song1 and song2 and does not play song3. Any ideas?

getAuthAsync is not a function, also getAuth is not a function

Hi,

I need the accessToken from login with spotify, but when I use getAuthAsync or getAuth this error appears:

_reactNativeSpotify2.default.getAuthAsync is not a function

_reactNativeSpotify2.default.getAuth is not a function

I checked RCTSpotify.h y RCTSpotify.m from ios folder and these methods not appears.

Thanks.

Playback stops when IOS locked or in background

Really great repo - thank you for putting this together!!

I recently used your project to create an IOS app that's in production. One thing I haven't been able to solve is how to get the music to continue playing in the background while the app is in the background or when the physical IOS device is locked. In the IOS simulator, everything just works. Is this possible?

I read somewhere that I needed to update my info.plist with the following:

    <array>
        <string>audio</string>
    </array>

Unfortunately that didn't help. This is nothing urgent, but I figured I'd reach out and ask if you had a solution.

Thanks!

how to find song ended?

I am trying to make a player and I want to listen to the song ended event or execute action based on song's end. Is there any way I can achieve this?

country arg for 'getArtistTopTracks()' weird error on IOS

This piece of code works perfectly fine on Android, but throws an error on IOS:

Spotify.getArtistTopTracks(
      "<artist-id>",
      { country: "GB" },
      {},
      (result, error) => ...

Error:

JSON value '{
    country = GB;
}' of type NSMutableDictionary cannot be converted to NSString

Authentication Service Unknown Error

Hello,

First of all, thank you for the amazing job so far!

I wasn't having any issues using your project in my app until I generated a signed release APK.

After that, every time I call the login method, this error appears:

error

Thanks!

queueURI is not working correctly

I have no clue how this works. I can play an individual track but I have no clue how to play through a playlist. Is there a function to just play through the queued songs in the playlist? i experimented with setPlaying but that does not play through the playlist. Thanks

Installing using yarn doesn't pull in submodule of the Spotify SDK

Submodules aren't retrieved when using yarn for dependencies from github.

To reproduce:

yarn https://github.com/lufinkey/react-native-spotify

This results in an empty external/SpotifySDK directory:

ls node_modules/react-native-spotify/ios/external/SpotifySDK

{empty result}

While it contain the submodule when installed via npm:

ls node_modules/react-native-spotify/ios/external/SpotifySDK

CHANGELOG.md                    LICENSE                         SpotifyAuthentication.framework
Demo Projects                   README.md                       SpotifyMetadata.framework
ISSUE_TEMPLATE.md               SpotifyAudioPlayback.framework  docs

I found an issue describing this behaviour: yarnpkg/yarn#1488 This issue also describes some workarounds, but they are all rather hackish.

My understanding is that if you properly release the package in the NPM registry (and not install it directly from Github) this won't be a problem.

Login window closes without logging in

Hi! New to this library and new to RN development, still learning :) To test out, I took your InitialScreen.js file and pasted it into my project and changed the class name to SpotifyLogin

I installed the npm module, moved the frameworks, and added them as framwork paths as instructed:
screen shot 2018-04-16 at 2 10 08 pm
screen shot 2018-04-16 at 2 10 50 pm

But I see this screen on my simulator:

undefined is not an object (evaluating 'nativeModule.__registerAsJSEventEmitter')

screen shot 2018-04-16 at 2 11 22 pm

My SpotifyLogin.js == InitialScreen.js so here is my App.js that pulls my screens together:

import React from 'react';
import { StackNavigator } from 'react-navigation';
import Home from './Home';
import Video from './Video';
import SpotifyLogin from './SpotifyLogin';

const App = StackNavigator({
Home: { screen: Home},
Video: { screen: Video },
SpotifyLogin: { screen: SpotifyLogin },
})

export default App;

Where do I look next to fix this problem?

Enhancement: Event handling

When a Spotify event occurs, the SDK fires events that would be very handy to have in any app that uses it.

For example, I currently have to send Web API requests every few seconds to find out whether my Spotify connect session was paused on a different device. The music just stops and I can't give any visual confirmation that the session was paused until my Web API request confirms it.

Android
https://spotify.github.io/android-sdk/player/com/spotify/sdk/android/player/PlayerEvent.html

iOS
Under the protocol references, several delegates are defined.
https://spotify.github.io/ios-sdk/

Would it be possible to pass some callback methods to these events that execute when they fire?
Allowing developers to subscribe to these events would be a serious enhancement to this module.
As an added plus, it'd give the module an edge over the current npm package react-native-spotify, which offers this functionality (but only on iOS!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.