Search code examples
iosiphoneibeaconios-bluetooth

iPhone: Paired Devices vs iBeacon Bluetooth Battery Consumption


I've 2 apps (1 that is registers and scans for iBeacons in the background, no ranging) and the other without. Both of these apps are essentially similar with the exception of 1st being enabled for iBeacons.

// location manager config
    + (CLLocationManager *)sharedLocationManager {
static CLLocationManager *_locationManager;

@synchronized(self) {
    if (_locationManager == nil) {
        _locationManager = [[CLLocationManager alloc] init];
    //_locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
        _locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
        _locationManager.pausesLocationUpdatesAutomatically = NO;
        if ([_locationManager respondsToSelector:@selector(allowsBackgroundLocationUpdates)]){
            _locationManager.allowsBackgroundLocationUpdates = YES;
        }
    }
}
return _locationManager;
}

    - (void)startMonitoringItem:(Item *)item {
    CLBeaconRegion *beaconRegion = [self beaconRegionWithItem:item];
    CLLocationManager *locationManager = [LocationTracker sharedLocationManager];
    [locationManager startMonitoringForRegion:beaconRegion];
}

- (void)stopMonitoringItem:(Item *)item {
    CLBeaconRegion *beaconRegion = [self beaconRegionWithItem:item];
    CLLocationManager *locationManager = [LocationTracker sharedLocationManager];
    [locationManager stopMonitoringForRegion:beaconRegion];
}

I've registered about a 100 iBeacons within the 1st app, and ran both apps on an iPhone 6 and an iPhone 6 Plus, running the same OS version within the vicinity of the 100 plus iBeacons, both with blue tooth enabled.

I'm only interested in entry and exit events, and essentially just implemented both of these calls in the 1st app. I ran the tests for about 14 hours, by just leaving both iPhones with bluetooth enabled within the vicinity of the iBeacons.

When I checked my battery status in my settings menu, the 1st app consumed at most 1% more battery than the 2nd app (eg: 1st app: 25%, 2nd app: 24%), which is the same on both devices. This is expected behaviour, as the blue tooth scanning algorithm controlled by iOS should be optimised to preserve battery.

However, on my client's device, the 1st app consumes 5x more battery than the 2nd app (eg: 1st app: 10%, 2nd app: 2%).

When I checked his bluetooth setting, I realized that his iPhone was paired with about 8 other devices.

So my question is this. Will pairing with other devices caused a much larger battery drain on my 1st app even though it is just scanning for iBeacons? If yes, is there any way I can optimized by algorithm to ignore paired devices and just scan for iBeacons.

I've read the iOS documentation extensively and consulting stackoverflow, but did not find a satisfactory answer so far.

I will greatly appreciate any advice!

Update: Please see screenshot for an example

Battery Consumption Percentages

In the above screenshot, the 1st and 2nd app battery usage percentages are nearly the same on my device. However, on my client's device (which is paired with 8 other devices), the 1st app was typically 5x more than the 2nd app battery usage percentage (eg: 10 % to 2 %), for both the last 24 hours and last 7 days. Both apps were running for approximately the same amount of time on his device. This is not the first time it has occured.


Solution

  • Yes, bluetooth pairing, especially classic bluetooth will use much more battery than scanning for beacons in the background on iOS.

    There is nothing you can do about pairing that is done outside your app. Apple's iOS sandboxes apps so they cannot affect general system settings (such as bluetooth on or off, or bluetooth pairing for things like tethering and speakers) or the behavior of other apps (like those that might pair with bluetooth devices for app-specific purposes.)

    The bottom line is that the battery usage you describe is not caused by your app's beacon scanning. It is caused by the pairing. If you uninstall the 1st app from your client's device, the device should drain the battery at a similar rate as if your app were not installed at all.