Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

'Guess the Artist' for iPhone, powered by the Rdio API

branch: master

Use Rdio 1.3.4

latest commit b5e509e831
kevin nelson rknLA authored September 30, 2013
Octocat-spinner-32 Classes First! May 06, 2011
Octocat-spinner-32 RDQuiz.xcodeproj Use Rdio 1.3.4 September 30, 2013
Octocat-spinner-32 Rdio.framework Use Rdio 1.3.4 September 30, 2013
Octocat-spinner-32 assets First! May 06, 2011
Octocat-spinner-32 resources First! May 06, 2011
Octocat-spinner-32 .gitignore Add github-recommended-default gitignore June 21, 2013
Octocat-spinner-32 RDQuiz-Info.plist First! May 06, 2011
Octocat-spinner-32 RDQuiz_Prefix.pch First! May 06, 2011
Octocat-spinner-32 README.md Remove iTunes link May 13, 2013
Octocat-spinner-32 main.m First! May 06, 2011
README.md

Rdio Quiz is a complete example of how to use the Rdio iOS library and API.

The goal of this project is to provide best practices of how to perform user authentication, music playback and perform API calls, as well as to give developers a general feel for what the library can do and how to integrate it into their applications.

Installation

Get a developer key and secret from developer.rdio.com and set the values in RDQuizAppDelegate.m

Usage

All tasks are accomplished with the Rdio class. To start using it create an instance of the Rdio object with your API key and secret.

Rdio *rdio = [[Rdio alloc] initWithConsumerKey:@"myKey" andSecret:@"mySecret" delegate:nil];

And in order to be informed when certain tasks complete you will need to implement a few delegate protocols:

  • RdioDelegate
  • RDPlayerDelegate
  • RDAPIRequestDelegate

Authentication

To access an Rdio user's information the user must authenticate with your application. Luckily, the Rdio library provides an easy to use authentication mechanism that takes care of all the heavy lifting for you.

To initiate authentication call - (void)authorizeFromController:(UIViewController *)currentController. This will present a login modal to the user, when the user completes logging in 1 of 3 delegate methods will be called: - (void)rdioDidAuthorizeUser:(NSDictionary *)user withAccessToken:(NSString *)accessToken if the user was successfully authenticated, - (void)rdioAuthorizationFailed:(NSString *)error if the user was not authenticated, and - (void)rdioAuthorizationCancelled if the user cancelled the login modal.

Upon successful authentication you should store the returned accessToken for future use so the user doesn't have to re-authorize your application. Then you can call - (void)authorizeUsingAccessToken:(NSString *)accessToken fromController:(UIViewController *)currentController and no user interaction is necessary. You cannot make any API calls that require authentication without first performing a successful authorize* call.

Playback

This is perhaps the most interesting functionality the Rdio library provides, it allows your application to stream Rdio music content. And it is extremely easy to use, simply access the player attribute of the Rdio object to access the instance of RDPlayer. To play a track call - (void)playSource:(NSString *)source with a track key (currently only single-track sources are supported). You can then use RDPlayer's methods to control playback (stop, pause, seek). Don't forget to add the UIBackgroundModes key with value of "audio" to your Info.plist to enable background audio playback.

Accessing Web Service API

The Rdio class provides a means of performing web service API calls and handling their results. To make an API call use - (RDAPIRequest *)callAPIMethod:(NSString *)method withParameters:(NSDictionary *)params delegate:(id<RDAPIRequestDelegate>)delegate your delegate will be notified when the request completes (successfully or not). See RDAPIRequest.h for more detail on delegate methods and the RDAPIRequest class.

Something went wrong with that request. Please try again.