Nis*_*ndi 0 bluetooth objective-c core-location ios ibeacon
我正在开发一个具有信标区域监控功能的应用程序。下面是监控信标区域的代码。
-(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];}
Run Code Online (Sandbox Code Playgroud)
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;
}
Run Code Online (Sandbox Code Playgroud)
现在的问题是,为了监控信标区域,iOS 设备必须启用蓝牙或其在不打开蓝牙的情况下工作?。我还参考了以下链接,但没有关于启用蓝牙进行区域监控的解释确定区域监控 的可用性
我用 kontakt.io 信标进行了测试,如果不打开设备上的蓝牙,它就无法工作,但当我读到区域监控正在位置服务上工作时,那么为什么我们需要启用蓝牙。所以每个信标都需要打开蓝牙,或者它是特定的到 kontakt.io 信标?
Apple 在 iOS 11 中进行了更改,即使用户在控制中心禁用蓝牙,操作系统仍会执行 iBeacon 设备的扫描和检测。(控制中心是在 iOS 上从屏幕底部向上滑动即可获得的快速访问窗格。)请参阅此处了解更多详细信息: https://support.apple.com/en-us/HT208086
上述说法不适用于 iOS 10.x 及更早版本,在控制中心关闭蓝牙将禁用信标检测。正如 @Paulw11 在他的回答中所述,您还必须在手机上启用位置功能,并且应用程序必须从应用程序获取动态位置权限才能检测到信标。
此外,在所有版本的 iOS 上,如果您转到“设置”->“蓝牙”并禁用蓝牙,它将禁用信标检测。
归档时间: |
|
查看次数: |
1555 次 |
最近记录: |