相关疑难解决方法(0)

使用iOS地理围栏跟踪多个(20+)位置

iOS应用程序使用地理围栏来通知用户有关预定义的附近位置.允许应用程序错过某个位置(用户没有收到有关附近位置的通知),但是希望保持较低的丢失率.

实现这一目标的一种方法是开始监控重要的变更位置,startMonitoringSignificantLocationChanges并且每次"位置变更"事件被触发时,查找位于报告位置的500米半径内的位置.

令我担心的是,每次发生重大位置变化时都需要对附近区域执行查询,这会影响电池.

另一种方法是注册地点,startMonitoringForRegion但Apple对同时跟踪的地区数量(合理)限制为20,我们有超过20个地点.因此需要对跟踪区域进行某种动态更新,但我仍然不确定最佳方法是什么.

有关如何做到这一点的任何想法,以便它保持低电池消耗,但也具有低位置的丢失率?

location cllocationmanager ios geofencing

30
推荐指数
3
解决办法
1万
查看次数

监控大型(50000+)区域的最佳方式

我想创建一个应用程序,当用户进入某个区域时,该应用程序执行特定操作.

由于我想要监控的区域位于服务器端(大约50,000个位置),并且区域数量太大而无法一次注册进行监控,我想开始监控接近当前位置的区域用户.

为了实现这一点,我正在考虑使用startMonitoringSignificantLocationChanges 监视用户是否已更改位置,然后使用locationManager:didUpdateToLocation:fromLocation: 注册新区域来监视和取消注册现在距离太远的区域.

我的问题:

  • 我是否允许didUpdateToLocation在应用程序处于后台时拨打网络服务 ?
  • 这是实现此类功能的最佳方式还是您知道更好的方法?

谢谢.

cllocationmanager ios

5
推荐指数
1
解决办法
352
查看次数

startMonitoringForRegion vs CLRegion:containsCoordinate

在我的IOS应用程序中,我正在实现地理围栏.在当前的实现中,我使用的代码如下:

  CLRegion* region3 = [[CLRegion alloc] initCircularRegionWithCenter:coordinates radius:100 identifier:@"region3"];
[self.locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyHundredMeters];
Run Code Online (Sandbox Code Playgroud)

然后我使用这些委托方法:

 (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{
        NSLog(@"didenterregion");

    }
    (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region{
        NSLog(@"didexitregion");
    }

    (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
    {NSLog(@"monitoringDidFailForRegion");}
Run Code Online (Sandbox Code Playgroud)

但是,此代码仅适用于大于100米的半径.

以下是一些问题:

  1. Apple称,在ios6及以上版本中,4s及以上的设备支持1到400m之间的半径.因为我不在乎需要多长时间才能看到这条消息(就像我不想在进入该地区时看到这条消息,但如果我从该地区过去过一次,我确实想看到后者)我可以使用较小的半径?我对50米半径或更小的东西感兴趣?(在某些地区,我的情况甚至需要20米).

我也想到了.Apple表示可以支持多达20个地区.像这样的溶剂有什么优点/缺点(我还没有实现,但我想要你的意见).

伪代码将是这样的:

Declare the regions - save them in an array
Do not call start monitoring
Run Code Online (Sandbox Code Playgroud)

然后在委托方法中:

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{
      for loop in all my regions {
         if ([region containsCoordinate: newLocation.coordinate])
            code for entering region
      } 
}
Run Code Online (Sandbox Code Playgroud)
  1. 它会慢吗?
  2. 它会消耗更多的电池吗?(我认为对地区进行监测并不耗电)?
  3. 它会更准确吗? …

mkmapview ios geofencing clregion

2
推荐指数
1
解决办法
1326
查看次数