【发布时间】:2017-11-02 06:42:23
【问题描述】:
我正在开发一个具有信标区域监控的应用程序。以下是监控信标区域的代码。
-(void)setBeaconMonitoringForUUID:(NSString *)strID withMajor:(NSString *)strMajor withMinor:(NSString *)strMinor withIdentifier:(NSString *)strIdentifier {
NSUUID *strUUID = [[NSUUID alloc] initWithUUIDString:strID];
CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:strUUID major:[strMajor intValue] minor:[strMinor intValue] identifier:strIdentifier];
[beaconRegion setNotifyEntryStateOnDisplay:YES];
[beaconRegion setNotifyOnEntry:YES];
[beaconRegion setNotifyOnExit:YES];
[self.objLocationManager startMonitoringForRegion:beaconRegion];
[self.objLocationManager startRangingBeaconsInRegion:beaconRegion];}
locationManager初始化如下
- (id)init
{
self = [super init];
if (self != nil)
{
self.objLocationManager = [CLLocationManager new];
self.objLocationManager.delegate = self;
self.objLocationManager.distanceFilter = 10.0;
self.objLocationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
self.objLocationManager.allowsBackgroundLocationUpdates = YES;
if ([self.objLocationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[self.objLocationManager requestAlwaysAuthorization];
}
[self.objLocationManager startUpdatingLocation];
}
return self;
}
现在的问题是为了监控信标区域,iOS 设备必须启用蓝牙或它在不打开蓝牙的情况下工作?我也参考了下面的链接,但没有关于启用蓝牙以进行区域监控的说明 Determining the Availability of Region Monitoring
我已经对 kontakt.io 信标进行了测试,如果不打开设备上的蓝牙,它就无法工作,但是当我读到区域监控正在使用位置服务时,那么为什么我们需要启用蓝牙。所以每个信标都需要打开蓝牙或它是特定于 kontakt.io 信标的吗?
【问题讨论】:
-
是的,当然。信标仅适用于蓝牙。因为与其他无线网络相比,蓝牙使用的电池非常少。当你的手机到达它的范围时,它会对你的手机执行它的操作。
-
标签: ios objective-c bluetooth core-location ibeacon