iBeacon Bluetooth didEnterRegion and didExitRegion methods are never fired

风流意气都作罢 提交于 2019-12-11 13:54:26

问题


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.


回答1:


Add startRangingBeaconsInRegion method after startMonitoringForRegion and try again

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



来源:https://stackoverflow.com/questions/24756019/ibeacon-bluetooth-didenterregion-and-didexitregion-methods-are-never-fired

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!