【问题标题】:didEnterRegion()/didExitRegion() never fired while application in the background or device lockeddidEnterRegion()/didExitRegion() 在后台应用程序或设备锁定时从未触发
【发布时间】:2014-07-16 03:09:27
【问题描述】:

这是基于iBeacon Bluetooth didEnterRegion and didExitRegion methods are never fired中的问题的进一步问题,已解决。

具体来说,didEnterRegion 和 didExitRegion 方法在信标应用程序在后台或设备锁定时不会触发。另外,这两种方法可以在beacon应用在前面时正常触发

我的应用程序基于以下链接中的苹果演示“Airlocated(示例代码,由苹果公司提供)”: https://developer.apple.com/library/ios/samplecode/AirLocate/Introduction/Intro.html#//apple_ref/doc/uid/DTS40013430-Intro-DontLinkElementID_2。我几乎没有修改任何代码除了添加一些代码如下:

在文件“APLAppDelegate.m”中

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
    NSLog(@"Entered region: %@", region);

    [self sendLocalNotificationForBeaconRegion:(CLBeaconRegion *)region];
}


- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
    NSLog(@"Exited region: %@", region);
}

在 APLMonitoringViewcontroller.m 文件中

- (void)updateMonitoredRegion
{
...

            [self.locationManager startMonitoringForRegion:region];
            [self.locationManager startRangeingForRegion:region];
...
}

补一下。我尝试了以下方法:

  • 将“位置更新”后台模式设置为“是”
  • 将 notifyOnExit 和 notifyOnEntry 指定为 true
  • 用 iOS 7.1.2 重启 iPhone4s

谁能给我一些建议?

【问题讨论】:

    标签: ios objective-c bluetooth cllocationmanager ibeacon


    【解决方案1】:

    您等待背景检测多长时间?在某些情况下,这可能需要长达 15 分钟。 See here for details.

    如那篇文章所述,您无需将位置更新背景模式设置为 YES,也无需将 notifyOnExit 和 notifyOnEntry 指定为 true。

    【讨论】:

    • 由于网络问题,抱歉回复晚了。感谢您对进入和退出信标区域的提醒,尤其是在应用程序处于后台时。我迷失了你文章中的相关观点。
    • 为了优化信标区域更改通知,似乎没有有效的解决方法来解决延迟问题,而 iBeacon 应用程序在后台而不是前台。是吗?
    • 你好大卫。回到 2021 年,您能否说背景检测是否仍需要 15 分钟?如果它的平均速度也很慢,或者这是罕见的最坏情况?
    • 这是一种罕见的最坏情况。较新的 iPhone 具有带有十几个或更多硬件过滤器的蓝牙芯片,用于快速检测。如果多个应用程序扫描蓝牙并使用所有这些插槽,那么下一个这样做的应用程序将获得缓慢的检测。这通常是仅在开发设备上存在的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-27
    • 1970-01-01
    • 2013-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多