【问题标题】:Region Monitoring not working in iOS if region don't have major如果区域没有专业,则区域监控在 iOS 中不起作用
【发布时间】:2017-11-29 07:22:38
【问题描述】:

在我的 iOs 应用程序中,我试图在不同的参数上监控一些信标区域,如下所示:

> 方法 1 - 只有 UUID 和标识符的区域:

在上述情况下,我开始使用以下监控信标区域 仅给出 uuid 和标识符的代码。

CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:convertedUuid identifier:strIdentifier]; 

方法 2 - 带有 UUID、主要和标识符的区域:

在上述情况下,我开始使用以下监控信标区域 给定 uuid、主要和标识符值的方法

CLBeaconRegion  *region = [[CLBeaconRegion alloc] initWithProximityUUID:convertedUuid  major:[self.major intValue] identifier:strIdentifier];

方法 3 - 带有主要次要和标识符的区域:

在上述情况下,我开始使用以下监控信标区域 给定所有 uuid、主要、次要和标识符值的方法

CLBeaconRegion  *region = [[CLBeaconRegion alloc] initWithProximityUUID:convertedUuid  major:[self.major intValue] minor:[self.minor intValue] identifier:strIdentifier];

现在考虑到以上 3 种方法,我开始使用以下方法进行区域监控:

[self.locationManager startMonitoringForRegion:region];

不幸的是,只有第三种方法信标进入和退出委托被调用。但是当我使用第一种或第二种方法时,我无法接收进入和退出区域委托。

注意:我不是一次运行所有方法。我一次只使用一种方法。

任何人都可以提供任何反馈或提供任何帮助,为什么其他区域方法不起作用但只有第三种方法起作用?

【问题讨论】:

  • @Bhavik 尝试添加这个方法 - (void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region { [self.locationManager startRangingBeaconsInRegion:self.myBeaconRegion]; }
  • 我看不出第一种方法行不通的任何原因。如果您在第一种不起作用的情况下在上下文中显示所有设置代码,这可能会有所帮助。我怀疑在这种情况下导致问题的代码设置方式存在一些细微差别,而问题不是您所怀疑的。
  • 我正在努力解决同样的问题。你找到解决方案了吗?
  • @Bhavik,您找到了解决方案。我有同样的问题。我想调用方法1。

标签: ios objective-c ibeacon region-monitoring clbeaconregion


【解决方案1】:

确保周围没有其他具有相同proximityUUID(方法1)或相同proximityUUID 和相同major(方法2)的信标。当有另一个信标时,应用程序将不会收到退出事件,因为它仍在此邻近UUID/major 定义的区域中。

【讨论】:

    猜你喜欢
    • 2015-12-09
    • 2015-02-07
    • 1970-01-01
    • 2014-05-23
    • 2011-07-17
    • 2013-11-20
    • 2018-05-21
    • 1970-01-01
    • 2018-08-04
    相关资源
    最近更新 更多