I have started to test out iBeacons using estimotes as beacons.
It\'s all running pretty good, but i\'m struggling with getting the app to run properly in the backgr
You do not need to call startUpdatingLocation
method.
startMonitoringForRegion
method starts monitoring the region only and call the didStartMonitoringForRegion
delegate method to let you know when beacon enter/exit the region.
You need to call startRangingBeaconsInRegion
method, which calls didRangeBeacons
delegate method which gives you array of detected beacons with UUID, major, minor, rssi info of beacons.
For background execution, just use UIBackgroundTaskIdentifier
and your code will work in background as well.
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(@"=== DID ENTER BACKGROUND ===");
UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
NSLog(@"End of tolerate time. Application should be suspended now if we do not ask more 'tolerance'");
}];
if (bgTask == UIBackgroundTaskInvalid) {
NSLog(@"This application does not support background mode");
}
else {
//if application supports background mode, we'll see this log.
NSLog(@"Application will continue to run in background");
}
}