【发布时间】:2015-09-24 12:15:36
【问题描述】:
我需要使用 Estimote 信标。
当应用程序在前台时LocationMangaer委托方法didEnterInRegion结束didExitRegion被正确调用,但是当应用程序在后台(锁定屏幕)时出现问题。
如果我把设备放在桌子上,如果我带着 Estimate 信标走开,几米后会调用方法 didExitRegion。
当我接近设备并进入信标区域(几厘米)时,方法didEnterInRegion 或方法didDetermineState 不会被调用。如果我解锁屏幕,几秒钟后,方法didEnterInRegion 会被调用。
这是我的代码:
NSUUID *beaconUUID = [[NSUUID alloc] initWithUUIDString:@"MYUUID"];
NSString *regionIdentifier = @"FuelPay";
CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:beaconUUID identifier:regionIdentifier];
beaconRegion.notifyOnExit = YES;
beaconRegion.notifyOnEntry = YES;
beaconRegion.notifyEntryStateOnDisplay = YES;
self.locationManager = [[CLLocationManager alloc] init];
if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[self.locationManager requestAlwaysAuthorization];
}
self.locationManager.delegate = self;
self.locationManager.pausesLocationUpdatesAutomatically = NO;
[self.locationManager startMonitoringForRegion:beaconRegion];
在 Info.plist 中,我设置了 NSLocationAlwaysUsageDescription 属性并在项目功能中启用了后台模式(使用“使用蓝牙 LE 附件”)。
怎么了?
非常感谢!
【问题讨论】:
标签: ios objective-c iphone bluetooth estimote