[RPTracker instance].isActive
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(observeTracker)
name:RPTrackerDidChangeActivityNotification
object:nil];
- (void)observeTracker {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.startButton.enabled = ![RPTracker instance].isActive;
self.stopButton.enabled = [RPTracker instance].isActive;
if ([RPTracker instance].isActive) {
self.tokenLabel.text = @"tracking is active";
} else {
self.tokenLabel.text = @"tracking is not active";
}
});
}
@interface AppDelegate () <RPSpeedLimitDelegate, RPTrackingStateListenerDelegate> {
}
@end
- (void)trackingStateChanged:(Boolean)state {
NSLog(@"tracking state changed to %hhu", state);
}
Manual start and stop tracking don't switch off automatic start / stop tracking. For manual start track you could use:
[[RPTracker instance] startTracking];
[[RPTracker instance] stopTracking];