iOS beacon 区域监控需要开启蓝牙

标签 ios objective-c bluetooth core-location 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];}

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 beacon 进行了测试,如果不打开设备上的蓝牙它就无法工作,但是当我读到区域监控正在定位服务上工作时,那么为什么我们需要启用蓝牙。所以每个信标都需要打开蓝牙或它特定于 kontakt.io 信标?

最佳答案

Apple 在 iOS 11 中做出更改,即使用户在控制中心禁用蓝牙,操作系统仍会执行 iBeacon 设备的扫描和检测。 (控制中心是您通过从 iOS 屏幕底部向上滑动获得的快速访问 Pane 。)有关更多详细信息,请参见此处:https://support.apple.com/en-us/HT208086

上述说法不适用于 iOS 10.x 及更早版本,在控制中心关闭蓝牙将禁用信标检测。正如 @Paulw11 在他的回答中指出的那样,您还必须在手机上启用定位功能,并且该应用程序必须先从该应用程序获得动态位置许可,然后才能检测到信标。

同样在所有版本的 iOS 上,如果您转到“设置”->“蓝牙”并禁用蓝牙,它将禁用信标检测。

关于iOS beacon 区域监控需要开启蓝牙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47069117/

相关文章:

php - Urban Airship 如何设置多个观众

javascript - PhoneGap iOS UIPicker 等效元素 : select an option value programmatically

ios - 我需要苹果 MFI 程序才能通过 USB 电缆访问 IOS 设备的短信吗?

ios - 基于 Cocoapods 的 iOS 项目的示例 .travis.yml

c# - 32feet连接蓝牙设备报错10049

iphone - 创建基本的内容浏览 iPhone 应用程序

objective-c - objc_setAssociatedObject with nil 要删除 - 是否检查了策略?

ios - XML 到对象 Objective-C

Android NearBy API 非常慢(发现和连接约 10 秒以上)

android - 如何在android中保存可发现的蓝牙设备列表?