ios - monitoringDidFailForRegion 为 iBeacon 区域时,kCLErrorDomain 错误 5

标签 ios monitoring core-location ibeacon ios7.1

我正在开发一个简单的应用程序,它使用 iOS7.1 中的 CoreLocation 来确定预设的 iBeacon。

我的代码在突然停止之前一直运行良好。我没有更改代码中的任何内容。

开始监视“ViewDidLoad”后,发生的错误是“monitoringDidFailForRegion”上的“kCLErrorDomain error 5”:

self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;

 NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"0E82E0A4-03FF-4A92-9C87-1F978917BD51"];
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"com.henry.beacon"];
self.beaconRegion.notifyEntryStateOnDisplay = YES;

if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]])
{
    NSLog(@"Monitoring is available.");
    [self.locationManager startMonitoringForRegion:self.beaconRegion];
    [self.locationManager requestStateForRegion:self.beaconRegion];
}

代理设置正确:

@interface ViewController : UIViewController <CLLocationManagerDelegate>

我检查了受监控的区域数量

[[self.locationManager monitoredRegions] count]

向我展示了 2 个区域目前正在受到监控。奇怪。

唯一有帮助的是重置 iOS 设备(带有 iOS7.1 的 iPad Mini)。之后监控区域数又回到1(应该是正确的)。

你们中有人遇到过同样的情况吗?我的代码有没有做错?这是 iOS 7.1 中的错误吗?

感谢任何评论/帮助。

亨利

更新:

我发现了另一个关于这个主题的话题,它提供了一些有趣的见解:

iBeacon: didRangeBeacons stops getting called, must reset device for it to work again

看来确实是iOS7.1的bug。感谢您对此发表评论。

最佳答案

检查您的蓝牙状态是打开还是关闭或蓝牙类型。可能是旧版本的蓝牙检查它。确保您的蓝牙已在设备中打开。这为我解决了这个错误。谢谢

关于ios - monitoringDidFailForRegion 为 iBeacon 区域时,kCLErrorDomain 错误 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23029197/

相关文章:

ios - 使用 Core Location 在 Apple Watch 上获得精确的室内位置更新?

ios - 如何使用 Swift 4 延长位置跟踪时间

iphone - 检测两个图像之间的像素碰撞/重叠

ios - 无效更新: invalid number of sections in UITableView

iphone - iOS:更新后核心位置关闭?

ruby-on-rails - 如何配置 munin 在 nginx 而不是 apache 上运行

python - 监控 celery ,我应该用什么?

iOS CoreLocation 没有获取 GPS 坐标

ios - 在 UITableView 中显示 Json 结果

hadoop - Apache Hama 和Hadoop Mapreduce 一样有监控网页吗?