2

I am using CLLocationManager object to start beacon ranging as per below code. Also enable the Background mode from Target -> Capabilities.

CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy=kCLLocationAccuracyBest;
locationManager.distanceFilter=kCLDistanceFilterNone;
locationManager.pausesLocationUpdatesAutomatically = NO;
[locationManager requestAlwaysAuthorization];

Also add the AllowsBackgroundLocatoinUpdates to YES

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) {
   locationManager.allowsBackgroundLocationUpdates = YES;
}

A Boolean value indicating whether the app wants to receive location updates when suspended.

Created on CLBeaconRegion object to range beacon like as

CLBeaconRegion *beacon_Region;
beacon_Region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid major:mjorVa minor:minorVa identifier:tmpStrIdentifier];
beacon_Region.notifyEntryStateOnDisplay = YES;
beacon_Region.notifyOnEntry=YES;
beacon_Region.notifyOnExit=YES;
[locationManager startRangingBeaconsInRegion:beacon_Region];

It's ranging in Background mode in some period of time like 10 minutes or some time 20 minutes but not in infinite.

Gautam Sareriya
  • 1,833
  • 19
  • 30

1 Answers1

0

How to maximize beacon responsiveness:

1.For the fastest monitoring detection times in the foreground, do ranging whenever you are monitoring, even if you don’t care about ranging updates. Like this:

CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6"] major: 1 minor: 1 identifier: @"region1"];
region.notifyEntryStateOnDisplay = YES;
[_locationManager startMonitoringForRegion:region];
[_locationManager startRangingBeaconsInRegion:region];

2.If you want to get a guaranteed extra monitoring update in the background whenever the users wakes up their phone, set the notifyEntryStateOnDisplay option on your region as so:

CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6"] major: 1 minor: 1 identifier: @"region1"];
region.notifyEntryStateOnDisplay = YES;
[_locationManager startMonitoringForRegion:region];

IF YOU WANT TO MORE THEN PLEASE FOLLOW THIS ARTICLE

Amit Srivastava
  • 1,105
  • 9
  • 18
  • Thanks for answer, but I want to range beacon in infinite time with background mode. Without breaking **didRangeBeacons:inRegion** method. – Gautam Sareriya Sep 15 '16 at 11:33