Search code examples
spotifycocoalibspotify-2.0libspotify

Enable sharing Spotify listening activity on Facebook via API?


Is it possible to enable sharing listening activity with Facebook from the Spotify API?

SPSession seems to have functions around scrobbling:

-(void)setScrobblingState:(sp_scrobbling_state)state forService:(sp_social_provider)service callback:(SPErrorableOperationCallback)block;

If not, is it possible to know if a user has enabled sharing to Facebook?

Edit: Thanks for the answer! Looks like there's an enum sp_social_provider that has a possible value SP_SOCIAL_PROVIDER_FACEBOOK for use with the following functions:

setScrobblingUserName:password:forService:callback:
setScrobblingState:forService:callback:

Solution

  • You can use SPSession's fetchScrobblingStateForService:callback: to find out if scrobbling to a particular service is enabled.

    To enable scribbling if it isn't enabled, you need to call setScrobblingUserName:password:forService:callback: to set credentials for the service, then setScrobblingState:forService:callback: to enable it.

    Set the state to SP_SCROBBLING_STATE_USE_GLOBAL_SETTING to keep the user's global preferences in your session (which is preferred).