0

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.

Qin Zhengquan
  • 467
  • 1
  • 8
  • 20
  • 1
    For the device that is paired with 8 other devices -- are those devices present when the reported battery drain occurs? If so, it is possible that iOS has a bug that is misreporting the battery drain as being the app when really it is a system level drain. – davidgyoung Dec 08 '15 at 00:12
  • Hi David, that is correct. Those devices are present and active when the drain occurs. I'll read up more to see if this bug is reported. Thanks so much once again. – Qin Zhengquan Dec 08 '15 at 00:26

1 Answers1

1

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.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Hi David, thanks so much for the quick update! Just a follow up, any idea why the battery usage for the pairing is counted under my 1st app? If I uninstall the 1st app, will the batt usage be counted another app that is using bluetooth scanning as well? – Qin Zhengquan Dec 07 '15 at 15:28
  • In my experience, bluetooth scanning and pairing shows up in settings as a system level battery usage not as an app level usage. – davidgyoung Dec 07 '15 at 19:38
  • Thanks for the clarification! But it still doesn't really explain why my client's bluetooth pairing, which has nothing to do with my 1st app that is jusy scanning for iBeacons, results in 5x more battery usage percentage than the 2nd app in the settings menu. I can't find the system level battery usage in the battery usage menu as it only shows the list of apps and their proportion of battery consumption. – Qin Zhengquan Dec 07 '15 at 19:57
  • can you attach a screenshot of what you are seeing? – davidgyoung Dec 07 '15 at 23:44
  • Thanks David! I've edited my question to include the screenshot along with additional clarifications. – Qin Zhengquan Dec 07 '15 at 23:59