Reputation: 764
I am developing an iOS7+ application with iBeacon
technology(Using estimote sdk 2.3.2). Now i am facing device battery drain issue while the app is running in foreground and background.
Has any option for ranging iBeacons
without using CLLocationManager
?
Upvotes: 1
Views: 514
Reputation: 12954
The only way to range iBeacons
is to use CoreLocation
, and unfortunately it is very power consuming.
However, you can turn on the Ranging
only when you need it. Monitoring
consumes much less energy and it is enough to find out if you are in iBeacon
range.
I have implemented a logic to store found iBeacons
with time when I last saw them. When Monitoring
informs me that I have met new iBeacon
(it can be an old one if we had left his range and went near it again) I start Ranging
:
- (void)beaconManager:(ESTBeaconManager *)manager didEnterRegion:(ESTBeaconRegion *)region {
[self.beaconManager startRangingBeaconsInRegion:self.beaconRegion];
}
and then in method method:
- (void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ESTBeaconRegion *)region {
}
I'm checking if I have seen this beacon within last hour. If I had I ignore it, and if not I do my logic. After that I'm stopping Ranging
:
[self.beaconManager stopRangingBeaconsInRegion:self.beaconRegion];
And then only Monitoring
is checking for new iBeacons
.
Upvotes: 1