Search code examples
iosobjective-cbluetoothcllocationmanageribeacon

iBeacon Bluetooth didEnterRegion and didExitRegion methods are never fired


It's very strange that didEnterRegion and didExitRegion are never fired after startMonitoringForRegion is called. In addition, didDetermineState could be triggered as expectation.

During the current stage, I only evaluate the iBeacon tech based on Apple's sample code demo, Airlocated.

Therefore, I only implement two methods, including didEnterRegion and didExitRegion in the file APLAppDelegate.m as bellow:

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
    NSLog(@"Entered region: %@", region);
    [self sendLocalNotificationForBeaconRegion:(CLBeaconRegion *)region];
}

- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
    NSLog(@"Exited region: %@", region);
}

Bellow steps have been tried, but no effect.

  • Reset iPhone5/iPhone4s with iOS7.1
  • Configure the background mode and *.plist as bellow:
  1. in project info or info.plist --> Custom IOS Target Properties --> . add "Required background modes" . in this add two items --> ."App shares data using CoreBluetooth" ."App registers for location updates"
  2. in project Capability --> There is Background Modes
    . check "Loaction update"
    . check "Acts as a Bluetooth LE accessory" . check "uses bluetooth LE accessories"
  • Authorize the application to access the device location.

So, could anyone give me some suggestion on it?

Thanks in advance.


Solution

  • Add startRangingBeaconsInRegion method after startMonitoringForRegion and try again

    [_locationManager startRangingBeaconsInRegion:demoRegion]; // demoRegion - region you have created