如何启用对区域监控服务的访问? [英] How do I enable access to region monitoring service?

查看:141
本文介绍了如何启用对区域监控服务的访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经简化了一下这个问题。当我在我的应用程序中创建和添加区域并询问这些区域的状态时,我在 monitoringDidFailForRegion 方法中看到以下内容:

I've simplified the question a bit. When I create and add regions in my app and interrogate the state of those regions I see the following in monitoringDidFailForRegion method:

无法完成操作。 (kCLErrorDomain错误4。)

检查 CLErrorDomain常量我看到错误4是 kCLErrorRegionMonitoringDenied ,它被描述为so:

Checking the CLErrorDomain constants I see that error 4 is kCLErrorRegionMonitoringDenied and it is described like so:

Access to the region monitoring service was denied by the user.

这怎么可能?这是我的设置和我检查的内容:

How is this possible? Here's my set up and what I've checked:


  • 我正在通过Xcode查看日志语句。

  • 我已经连接到我的iPhone 5.我没有在模拟器中运行。

  • 我确保半径足以监控(尽管它不应该问题)。

  • 我已确保我的设备启用了设置>隐私>位置服务 我的应用。

  • 我已经阅读了Apple发布过的每个核心位置和区域监控文档。

  • 我已确保WiFi已打开并且我有一个强大的蜂窝信号。如果我没有,它将无法在第一时间找到我的位置。

  • 我确保 didChangeAuthorizationStatus 报告正确的状态: kCLAuthorizationStatusAuthorized

  • 我确保在添加我的区域之后监控确实通过观察对方法 didStartMonitoringForRegion

  • I am working through Xcode to watch log statements.
  • I am connected to my iPhone 5. I am not running in the simulator.
  • I have ensured that the radius is sufficient in size to be monitored (though it shouldn't matter).
  • I have ensured that Settings > Privacy > Location Services is on for my device and my app.
  • I've read every Core Location and Region Monitoring document Apple has ever published.
  • I have ensured that WiFi is on and that I have a strong cellular signal. If I didn't it wouldn't be able to find my location in the first place.
  • I have ensured that didChangeAuthorizationStatus reports the correct status: kCLAuthorizationStatusAuthorized
  • I have ensured that after adding my region that monitoring does in-fact begin by observing the call to the method didStartMonitoringForRegion.

我缺少什么?为什么在明确启用位置服务时会看到此错误?

What am I missing? Why do I see this error when Location Services are clearly enabled?

推荐答案

所以,我又看了一眼有关区域监控的文档,我在列表中突出显示的项目中注意到了这一点:

So, I took yet another look at the documentation on Region Monitoring and I noticed this in the highlighted item in the list:


确定区域监控的可用性

在尝试监控任何区域之前,您的应用应检查当前设备是否支持区域监控。可能无法进行区域监控的原因有多种:

Before attempting to monitor any regions, your app should check to see if region monitoring is supported on the current device. There are several reasons why region monitoring might not be available:


  • 设备可能没有支持区域监控所需的硬件。

  • 用户可能已拒绝该应用授权使用区域监控。

  • 用户可能已在设置应用中禁用了位置服务。

  • 用户可能已在设置应用中为设备或应用禁用了后台应用刷新功能。

  • 设备可能处于飞行模式,无法启动必要的硬件。

  • The device may not have the hardware needed to support region monitoring.
  • The user might have denied the app the authorization to use region monitoring.
  • The user may have disabled location services in the Settings app.
  • The user may have disabled Background App Refresh in the Settings app, either for the device or for your app.
  • The device might be in Airplane mode and unable to power up the necessary hardware.

然后我检查了后台应用程序刷新(iOS 7中的新功能:设置>常规>后台应用程序刷新)已打开并可用于我的应用程序。 不是 。我打开了这个功能,BOOM我的地区现在正在报告他们的状态。

Then I checked that Background App Refresh (a new feature at iOS 7: Settings > General > Background App Refresh) is turned on and available for my app. It was not. I turned the feature on and BOOM my regions are reporting their state now.

令人困惑和误导:

[CLLocationManager isMonitoringAvailableForClass:[CLRegion class]] returns YES 

...即使禁用后台应用程序刷新。我认为它会返回NO。

...even when Background App Refresh is disabled. I would think it would return NO.

更新:

我已发送向Apple发送错误报告并为此问题添加了一个Open Radar

I have sent a bug report to Apple and added an Open Radar for this issue.

更新3-11-14:

Apple确认这是一个错误。

Apple has confirmed that this is a bug.

这篇关于如何启用对区域监控服务的访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆