Inconsistent Background Location Updates in iOS App Across Different Devices

I’ve developed an iOS app by react-native that requires background location updates. The app works perfectly on my phone, providing frequent location updates as expected. However, on some other devices, the location updates occur only once every 15 minutes, exactly, which is problematic for my app’s functionality.

Details:

  • Location Services: Enabled and set to “Always” on both devices.
  • Battery Optimization: Low Power Mode is turned off on the other devices.
  • Permissions: The app has the necessary permissions (NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription) in the Info.plist file.
  • Background Modes: The location background mode is enabled in the app’s capabilities.
  • Implementation: Using the standard location service with appropriate accuracy and distance filter settings.

Relevant Code Snippet:

- init {
    self = [super init];
    if (self) {
        self->locationManager = [[CLLocationManager alloc] init];
        self->locationManager.delegate = self;
    }
    return self;
}

RCT_EXPORT_METHOD(startGeolocationTracking:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
    self->locationManager.distanceFilter = kCLDistanceFilterNone;
    self->locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    self->locationManager.allowsBackgroundLocationUpdates = YES;
    self->locationManager.pausesLocationUpdatesAutomatically = NO;
    self->locationManager.activityType = CLActivityTypeOtherNavigation;
    [self->locationManager startUpdatingLocation];
    [self->locationManager startMonitoringSignificantLocationChanges];
    resolve(nil);
}

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
    CLLocation *location = locations.lastObject;
    NSLog(@"applog location: %@", location);
    [self sendEventWithName:@"onGeolocation" body:@{
        @"errorCode": @0,
        @"latitude": @(location.coordinate.latitude),
        @"longitude": @(location.coordinate.longitude),
        @"direction": @(location.course),
        @"speed": @(location.speed),
        @"altitude": @(location.altitude),
        @"accuracy": @(location.horizontalAccuracy),
        @"timestamp": @([location.timestamp timeIntervalSince1970] * 1000),
        @"count": @(locations.count),
    }];
}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
    NSLog(@"applog location error: %@", error);
    [self sendEventWithName:@"onGeolocation" body:@{
        @"errorCode": @1,
        @"error": error.localizedDescription,
    }];
}

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
    NSLog(@"applog location authorization status: %d", status);
    [self sendEventWithName:@"onGeolocation" body:@{
        @"errorCode": @1,
        @"auth": @(status),
    }];
}

- (void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager {
    NSLog(@"applog location pause");
    [self sendEventWithName:@"onGeolocation" body:@{
        @"errorCode": @1,
        @"status": @"pause",
    }];
}

- (void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager {
    NSLog(@"applog location resume");
    [self sendEventWithName:@"onGeolocation" body:@{
        @"errorCode": @1,
        @"status": @"resume",
    }];
}

- (void)locationManager:(CLLocationManager *)manager didFinishDeferredUpdatesWithError:(NSError *)error {
    NSLog(@"applog location deferred error: %@", error);
    [self sendEventWithName:@"onGeolocation" body:@{
        @"errorCode": @1,
        @"deferred": error.localizedDescription,
    }];
}

RCT_EXPORT_METHOD(stopGeolocationTracking:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
    [self->locationManager stopUpdatingLocation];
    [self->locationManager stopMonitoringSignificantLocationChanges];
    resolve(nil);
}

RCT_EXPORT_METHOD(requestLocation:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
    dispatch_async(dispatch_get_main_queue(), ^{
        [self->locationManager requestLocation];
        resolve(nil);
    });
}

Observations:

  • The issue is device-specific; it works fine on my phone but not on others.
  • The app’s background location updates are being throttled on some devices, updating only every 15 minutes, no more, no less.

Steps Taken:

  • Verified location services settings.
  • Ensured Low Power Mode is off.
  • Checked Info.plist for necessary permissions.
  • Enabled location background mode in capabilities.
  • It doesn’t work neither when running in the foreground, background, or killed by task manager.

Questions:

  • What could be causing the background location updates to be throttled on certain devices?
  • Are there any additional settings or configurations I should check or implement to ensure consistent background location updates across all devices?

Any help or insights would be greatly appreciated. Thank you!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật