RunKeeper-iOS 0.0.1

RunKeeper-iOS 0.0.1

LangLanguage Obj-CObjective C
License BSD
ReleasedLast Release Dec 2014

Maintained by Unclaimed.

Depends on:
AFNetworking~> 1.2.0
NXOAuth2Client~> 1.2.0

  • By
  • Brierwood Design and Reid van Melle

RunKeeper-iOS provides an Objective C wrapper class for accessing the RunKeeper Health Graph API from iOS 4.0 or newer.

RunKeeper-iOS was developed for use in our iPhone fitness app "Running Intensity". It is meant to be general, but is built primarily for a Running app. The API is NOT fully supported, but more will be added based on our own needs or the requests of others.


  • ASI HTTP Request - Used for the underlying network access
  • SBJson - Needed for parsing the response from
  • OAuth2Client - Used for OAuth2 access to RunKeeper API
  • You will also need to register for a RunKeeper account, create an app, and get your tokens

Example Usage

Saving GPS Points

The RunKeeper will automatically create a correctly timestamped path for you if you post notifications.

  RunKeeperPathPoint *point = [[[RunKeeperPathPoint alloc] initWithLocation:newLocation ofType:kRKGPSPoint] autorelease];
  [[NSNotificationCenter defaultCenter] postNotificationName:kRunKeeperNewPointNotification object:point];

Posting a Run

  [self.runKeeper postActivity:kRKRunning start:[NSDate date] 
                distance:[NSNumber numberWithFloat:10000]
                duration:[NSNumber numberWithFloat:[self.endTime timeIntervalSinceDate:self.startTime] + elapsedTime]
                   notes:@"What a great workout!" 
                     UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Success" 
                                                                      message:@"Your activity was posted to your RunKeeper account."
                                                                     delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
                     [alert show];

                  failed:^(NSError *err){
                      NSString *msg = [NSString stringWithFormat:@"Upload to RunKeeper failed: %@", [err localizedDescription]]; 
                      UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Failed" 
                                                                      delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
                      [alert show];

See more examples in the attached sample project.

Getting Started

Create a RunKeeper Instance with your Secret Keys

  self.runKeeper = [[[RunKeeper alloc] initWithClientID:kRunKeeperClientID clientSecret:kRunKeeperClientSecret] autorelease];

Register a URL Scheme

Your URL Scheme is constructed by taking your RunKeeper ClientID and prepending "rk" --- an example is "rk055cac1c950b46e6ac7910d62800a854". The URL scheme is registered in your app's Info.plist file in order to receive redirects from OAuth2.

Handle the Redirect

In your application delegate:

  - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

    [self.runKeeper handleOpenURL:url];
    return TRUE;

Authorize the User

You begin by trying to connect to RunKeeper. If the user previously authorized the app and the access token, is still available, the connection will happen immediately and without any intervention:

  [[AppData sharedAppData].runKeeper tryToConnect:self];

If the user has not granted authorization OR the access token has been lost/deleted, your delegate method needsAuthentication will be called. In this method, you can request authorization via OAuth.

  - (void)needsAuthentication {
    [[AppData sharedAppData].runKeeper tryToAuthorize];

More Info

Check out the sample app to see a very simple integration.

Feel free to add enhancements, bug fixes, changes and provide them back to the community!


Reid van Melle