*Tracking Status

Check Tracking status with next Objective-c:

[RPTracker instance].isActive

Detect state changes with Notification: Objective-c:

[[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(observeTracker)
     name:RPTrackerDidChangeActivityNotification
     object:nil];

and Observer Objective-c:

- (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";
        }
    });
}

Detect state changes with Delegate: RPTrackingStateListenerDelegate Objective-c:

@interface AppDelegate () <RPSpeedLimitDelegate, RPTrackingStateListenerDelegate> {
    
}

@end

Delegate Method Objective-c:

- (void)trackingStateChanged:(Boolean)state {
    NSLog(@"tracking state changed to %hhu", state);
}

Start / Stop Tracking

Manual start and stop tracking don't switch off automatic start / stop tracking. For manual start track you could use:

[[RPTracker instance] startTracking];

For manual stop track you could use:

[[RPTracker instance] stopTracking];

Last updated