-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Summary
I observed when using the Radar iOS SDK, both startUpdatingLocation and a periodic requestLocation may trigger location updates simultaneously under certain configurations. While this behavior might be intentional for specific use cases, it could lead to redundant location updates, potentially impacting efficiency or battery performance in scenarios where both methods are active.
Code to reproduce
- (void)startUpdates:(int)interval blueBar:(BOOL)blueBar {
if (!self.started || interval != self.startedInterval) {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(shutDown) object:nil];
if (self.timer) {
[self.timer invalidate];
}
// Periodic location request
self.timer = [NSTimer scheduledTimerWithTimeInterval:interval
repeats:YES
block:^(NSTimer *_Nonnull timer) {
[self requestLocation];
}];
// Continuous location updates
if (blueBar && interval <= 5) {
[self.locationManager startUpdatingLocation];
} else {
[self.locationManager stopUpdatingLocation];
}
self.started = YES;
self.startedInterval = interval;
}
}Steps to reproduce
- Configure the SDK to call both startUpdatingLocation and requestLocation in the same session.
- Set interval to 5 or lower and enable blueBar.
- Observe didUpdateLocations being called multiple times within a short period due to overlapping location requests.
OS version
iOS 16.0 and above (confirmed on iOS 16.5 and iOS 17.0).
SDK installation method
CocoaPods
SDK version
3.4.1
Other information
I understand that the simultaneous usage of startUpdatingLocation and requestLocation could be intentional for some use cases. However, in scenarios where efficiency and battery usage are critical, avoiding redundant location updates might improve overall performance.
Would it be possible to:
- Automatically manage the overlap between startUpdatingLocation and requestLocation calls?
- Provide an additional configuration option to toggle between continuous and periodic location requests?
This is more of a suggestion to explore potential enhancements rather than a bug report. I highly appreciate the work that has gone into the SDK and look forward to any insights or recommendations you may have.