【问题标题】:Wake Application from Suspended state on Beacon Enter taking too long从 Beacon Enter 上的挂起状态唤醒应用程序花费的时间太长
【发布时间】:2016-06-22 19:14:59
【问题描述】:

我有一个监控 iBeacons 的应用程序。当应用程序从挂起状态终止,然后进入它正在监视的信标区域时,有时可能需要很长时间(有时长达 1 分钟)才能唤醒应用程序(调用 didEnterRegion 或 didExitRegion)。对此我能做些什么吗?这是我在应用程序进入后台时使用的代码

- (void)extendBackgroundRunningTime {
    if (_backgroundTask != UIBackgroundTaskInvalid) {
        // if we are in here, that means the background task is already running.
        // don't restart it.
        return;
    }
    // Attempt to extend background time by initializing a placeholder background thread
    __block Boolean self_terminate = YES;
    _backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithName:kBISBeaconManagerKeyBackgroundTask expirationHandler:^{
        // Background task expired, completion
        if (self_terminate) {
            NSLog(@"Application Terminated");
            [[UIApplication sharedApplication] endBackgroundTask:_backgroundTask];
            _backgroundTask = UIBackgroundTaskInvalid;
        }
    }];
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        // Background task started
    });
}

【问题讨论】:

    标签: ios core-location ibeacon


    【解决方案1】:

    一些想法:

    • 问题中显示的代码延长了后台信标测距时间。它不会影响信标监控(监控 API 是提供 didEnterRegion 和 didExitRegion 回调的东西)。

    • 监控响应时间可能会有很大差异。 最好的情况是,didEnterRegion 回调将在信标进入范围后的一秒或两秒内触发。 didExitRegion 事件总是额外延迟 30 秒(这是 iOS 在确定不再可见信标之前等待的时间。)

    • 如果所有 30 个蓝牙硬件加速插槽都被占用,则无法满足最佳情况场景时间。这些插槽位于手机上的所有应用程序中。如果您的应用尝试在所有时隙被占用时监控信标区域,检测时间会退回到软件备份周期,可能需要 15 分钟

    查看此处了解更多信息: http://developer.radiusnetworks.com/2014/03/12/ios7-1-background-detection-times.html

    http://developer.radiusnetworks.com/2015/04/21/max-beacon-regions-ios.html

    【讨论】:

    • 好的,这是有道理的。不知道 30 个插槽
    猜你喜欢
    • 2021-05-26
    • 2017-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多