iOS - 关闭WiFi的地理围栏 [英] iOS - Geofencing with WiFi turned off

查看:305
本文介绍了iOS - 关闭WiFi的地理围栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码在我的iPhone上创建了一个geofence,当didExitRegion被调用时会触发一些代码被执行。但是,我发现,当我关闭WiFi时,didExitRegion永远不会被触发。
是否需要WiFi才能监控iOS上的区域更改?
我希望的精度设置为kCLLocationAccuracyHundredMeters。
我正在iOS 6.1和iPhone 4上进行测试。



这是我设置位置监控的代码:

   - (id)init {
self = [super init];
if(self){
CLLocationManager * manager = [[CLLocationManager alloc] init];
manager.delegate = self;
manager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
manager.distanceFilter = RADIUS / 10.0;
manager.headingFilter = kCLHeadingFilterNone;
self.locationManager = manager;
self.authorizationStatus = [CLLocationManager authorizationStatus];
}
返回自我;

谢谢

解决方案

iOS设备使用三种方法来发现用户位置。从(通常)最准确到最不准确的是:


  1. GPS硬件

  2. 无线网络
  3. Cell Tower Triangulation

如果您的应用不使用GPS或不运行(即先前已被终止),设备将尝试使用上述方法2和3来定位用户。因此,设备定位用户的能力(在GPS硬件未使用或GPS信号较弱时)取决于WiFi网络和蜂窝塔的可用性。无线网络和蜂窝塔越多,定位精度就越好。因此,当用户进入或退出监控区域(即跨越地理围栏)时,无法准确预测用户何时会收到通知。 (当然,如果所讨论的区域总是相同的,那么设备将或多或少地以相同程度的精度定位用户)。

这里是来自位置感知编程指南


具体的阈值距离由硬件和位置技术确定目前可用。例如,如果Wi-Fi已禁用,则区域监控的精确度会大大降低。然而,出于测试目的,您可以假设最小距离大约为200米。


因此,区域监控不需要wifi工作,但启用它后,您的设备将有更好的机会确定用户是否跨越了某个地区的地理围栏。


I have code that creates a geofence on my iPhone that will trigger some code to be executed when didExitRegion gets called. However, I have found that when I have WiFi switched off that didExitRegion never gets triggered. Is WiFi required for monitoring region changes on iOS? My desired accuracy is set to kCLLocationAccuracyHundredMeters. I am testing on iOS 6.1 and iPhone 4.

Here is my code for setting up location monitoring:

- (id)init {
self = [super init];
if (self) {
    CLLocationManager *manager = [[CLLocationManager alloc] init];
    manager.delegate = self;
    manager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
    manager.distanceFilter = RADIUS/10.0;
    manager.headingFilter = kCLHeadingFilterNone;
    self.locationManager = manager;
    self.authorizationStatus = [CLLocationManager authorizationStatus];
}
return self;
}

Thanks

解决方案

iOS devices use three methods to discover user location. From (usually) most accurate to least accurate they are:

  1. GPS hardware
  2. By identifying nearby wifi networks
  3. Cell Tower Triangulation

If your app doesn't use GPS or is not running (ie. has previously been terminated), the device will attempt to use methods 2 and 3 above to locate the user. So the device's ability to locate the user (when the GPS hardware is not in use or there is a weak GPS signal) depends on the availability of wifi networks and cell towers. The more wifi networks and cell towers, the better the location accuracy. Therefore, when a user enters or exits a monitored region (ie. crosses a "geofence"), it is impossible to predict exactly when the user will receive the notification if at all. (Of course, if the region in question is always the same, the device will more or less locate the user with the same degree of accuracy on each occasion).

Here's the relevant documentation from the Location Awareness Programming Guide:

The specific threshold distances are determined by the hardware and the location technologies that are currently available. For example, if Wi-Fi is disabled, region monitoring is significantly less accurate. However, for testing purposes, you can assume that the minimum distance is approximately 200 meters.

So, wifi is not required for region monitoring to work, but with it enabled, your device will have a better chance in determining whether or not the user has crossed a region's geofence.

这篇关于iOS - 关闭WiFi的地理围栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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