iBeacon:didRangeBeacons停止呼叫,必须重置设备才能重新工作

我正在使用自定义的BeaconManager委托,以便信标测距不是由视图控制器的生命周期决定的。 一切都很好,但是每隔一段时间(1-2天),指示灯就会停止工作,而且Range信道也不会被叫到。 解决这个问题的唯一方法就是重置我的iPhone,一旦我这样做,它就可以完美的工作。 以下是我正在使用的代码。 基本的stream程是,当我的ViewController调用ViewDidLoad它发送一个通知回到AppDelegate告诉它开始测距信标,我从来没有告诉它停止,因为我希望它继续范围的信标无论用户导航在应用程序中。 我想知道如果我的代码是造成这个,或者这只是一个蓝牙的错误。 谢谢你的帮助!

BeaconManager.m

#import "BeaconManager.h" #import "AppDelegate.h" @interface BeaconManager()<CLLocationManagerDelegate> @property (nonatomic, strong) CLLocationManager *locationManager; @property (nonatomic, strong) CLBeaconRegion *beaconRegion; @end @implementation BeaconManager + (id)sharedManager { static BeaconManager *sharedBeaconManager = nil; static dispatch_once_t once; dispatch_once(&once, ^{ sharedBeaconManager = [[self alloc] init]; }); return sharedBeaconManager; } - (id)init { self = [super init]; if(self) { self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; } return self; } - (void)startBeaconMonitoring:(NSString*)forUUID { NSUUID * uuid = [[NSUUID alloc] initWithUUIDString:forUUID]; self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"com.beacons.publicRegion"]; [self.locationManager startMonitoringForRegion:self.beaconRegion]; [self.locationManager startRangingBeaconsInRegion:self.beaconRegion]; } - (void)stopBeaconMonitoring { //Stop the region monitoring if(self.locationManager != nil && self.beaconRegion != nil) { [self.locationManager stopRangingBeaconsInRegion:self.beaconRegion]; } } #pragma mark - CLLocationManagerDelegate - (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region { self.beacons = beacons; if(self.delegate != nil) { [self.delegate beaconManager:self didRangeBeacons:self.beacons]; } } @end 

ViewController.m

 @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] postNotificationName:@"startRanging" object:nil userInfo:nil]; } 

AppDelegate.m

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startRangingForZombies) name:@"startRanging" object: nil]; return YES; } - (void)startRanging { //Start the beacon region monitoring when the controller loads BeaconManager *beaconManager = [BeaconManager sharedManager]; beaconManager.delegate = self; [beaconManager startBeaconMonitoring:@"1234-54324-34242-34242-43243"]; } 

我们在Radius Networks收到许多停止检测iBeacon的报告,需要重新启动或closures蓝牙,然后再重新开始解决问题。 人们已经在iPhone 4S,iPhone 5s,iPhone 5c和iPad上报道了这一点。

我没有任何确凿的证据表明,这是iOS 7.1的破坏,但是自发布以来,报告频率已经上升。 间接的证据是相当强大的。

当这个手机进入这个状态,手机仍然可以扫描蓝牙设备 ,并仍然可以作为iBeacon传输。 因此这不是蓝牙的硬件问题。 根据现有证据,这很可能是CoreLocation中新引入的一个bug。

实际上,这是iOS 7.1中的一个已知错误。 对于最新版本的iOS来说,这严格是蓝牙堆栈的软件问题。 蓝牙设备检测有时会停止工作 – 不幸的是,所有iOS 7.1兼容设备都是这种情况。 这个漏洞已经报告给苹果公司,但是只要他们不解决这个问题,最好的办法就是重启设备。

如果重新启动没有帮助,SmartRobotic上有关于如何解决它的方便的指南: http ://www.smartbotics.com/#!4-Tips-to-Fix-Bluetooth-Problems-After-iOS-71-Upgrade / c118r / 031A86F6-C8E8-4768-B4FD-E6F83D9E4317

干杯。

苹果公司在7.1版本中引入了对蓝牙LE的重要改变,但也打破了内部。

从我的实验中:

  • iPhone 4S 7.x – iBeacons就像一个魅力

  • 2×iPhone 4S 7.1,2×iPhone 5 7.1 – 工作正常,但需要不时重新启动(不确定)。

它看起来像系统问题 – 一个大问题。 我已经联系了Estimote – 他们知道这件事。

有趣的事实:你无法find信标 – 即使estimote演示应用程序不能,委托方法不叫,但你可以把(坏)设备变成一个信标,它会被其他设备发现。

免责声明:我目前在sensorberg工作,我们销售信标和SDK。

我们也有很多关于这个bug的报道。 我们要求我们的所有客户向苹果提交错误报告。 以下是您可以使用的模板: https : //gist.github.com/anonymous/5283b6941e1f7d4e4461

一旦我能够logging下来,我个人有过两次这样的行为: https : //www.youtube.com/watch?v=6a6IJzaxxJg只有重新启动设备才有帮助。

继续提交Apple rdar错误报告!

我有类似的问题,但经过一段时间的调查后,我意识到,调用startMonitoringForRegion(region)和startRangingBeaconsInRegion(region)之后是相互错误的。 这就是你(Patrick)所做的:

 - (void)startBeaconMonitoring:(NSString*)forUUID { NSUUID * uuid = [[NSUUID alloc] initWithUUIDString:forUUID]; self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"com.beacons.publicRegion"]; [self.locationManager startMonitoringForRegion:self.beaconRegion]; [self.locationManager startRangingBeaconsInRegion:self.beaconRegion]; } 

而是应该在locationManagerDelegate方法locationManager(manager:CLLocationManager !, didDetermineState状态:CLRegionState,forRegion区域:CLRegion!)(在本例中是Swift代码)中调用startRangingBeaconsInRegion(region)。 这是我的解决scheme。

这是有道理的,因为第一步是在该地区find任何信标,第二个是从已经监控的信标中获得特定的信息。