Skip to content
Browse files

couple fixed + added more README info

  • Loading branch information...
1 parent cc092c8 commit 071f73f8ee869d65bfeac9807e37af90c6dad2ad @rvanmelle rvanmelle committed
View
16 README.md
@@ -73,6 +73,22 @@ In your application delegate:
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
View
2 runkeepersample/runkeepersample/RootViewController.h
@@ -30,7 +30,7 @@ typedef enum {
}
@property (nonatomic, retain) CLLocationManager *locationManager;
-@property (nonatomic, retain) NSDate *startTime, *endTime;
+@property (nonatomic, retain) NSDate *beginTime, *startTime, *endTime;
@property (nonatomic, retain) NSTimer *tickTimer;
@property (nonatomic, retain) IBOutlet UILabel *progressLabel;
@property (nonatomic, retain) IBOutlet UIButton *startButton, *pauseButton, *disconnectButton, *connectButton;
View
8 runkeepersample/runkeepersample/RootViewController.m
@@ -33,7 +33,7 @@ + (NSString*)stringWithTimeInterval:(NSTimeInterval)interval tenths:(BOOL)tenths
@implementation RootViewController
@synthesize progressLabel, startButton, pauseButton, disconnectButton, connectButton;
-@synthesize tickTimer, startTime, endTime, locationManager;
+@synthesize tickTimer, startTime, endTime, beginTime, locationManager;
- (void)updateViews
{
@@ -82,8 +82,8 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto
{
if (buttonIndex == 1) {
RunKeeper *rk = [AppData sharedAppData].runKeeper;
- [rk postActivity:kRKRunning start:[NSDate date]
- distance:[NSNumber numberWithFloat:10000]
+ [rk postActivity:kRKRunning start:self.beginTime
+ distance:nil
duration:[NSNumber numberWithFloat:[self.endTime timeIntervalSinceDate:self.startTime] + elapsedTime]
calories:nil
heartRate:nil
@@ -112,6 +112,7 @@ - (IBAction)toggleStart
state = kRunning;
elapsedTime = 0;
self.startTime = [NSDate date];
+ self.beginTime = self.startTime;
[self.startButton setTitle:@"STOP" forState:UIControlStateNormal];
self.pauseButton.hidden = NO;
RunKeeperPathPoint *point = [[[RunKeeperPathPoint alloc] initWithLocation:self.locationManager.location ofType:kRKStartPoint] autorelease];
@@ -124,6 +125,7 @@ - (IBAction)toggleStart
[tickTimer invalidate];
self.tickTimer = nil;
self.endTime = [NSDate date];
+ elapsedTime += [self.endTime timeIntervalSinceDate:self.startTime];
RunKeeperPathPoint *point = [[[RunKeeperPathPoint alloc] initWithLocation:self.locationManager.location ofType:kRKEndPoint] autorelease];
[[NSNotificationCenter defaultCenter] postNotificationName:kRunKeeperNewPointNotification object:point];
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Upload?"

0 comments on commit 071f73f

Please sign in to comment.
Something went wrong with that request. Please try again.