Bre*_*ett 43 objective-c core-location ios geofencing
我已经阅读了许多关于地理围栏我的iOS应用程序的教程(例如,这里),但没有提到iOS是否允许在关闭应用程序时处理任何特定于应用程序的位置数据.
例如,据我所知,当应用程序处于后台时,这些服务仍然会持续存在(如果编码正确),但是当用户双击主页按钮并关闭应用程序时呢?还能获得位置数据吗?
Dan*_*iel 67
According to the Apple Documentation, in the Using Regions to Monitor Boundary Crossings section:
In iOS, the regions you register with the location manager persist between launches of your application. If a region crossing occurs while your iOS app is not running, the system automatically wakes it up (or relaunches it) in the background so that it can process the event. When relaunched, all of the regions you configured previously are made available in the monitoredRegions property of any location manager objects you create.
So yes, your application will be woken up (or relaunched!) when the system's location detects you entered/exited (depending on your setup) a desired region, so this is even if your app isn't running of course. You just need to handle it correctly in the application delegate, when the app is relaunched you get passed a UIApplicationLaunchOptionsLocationKey key in the options dictionary. See documentation link below for details.
Please remember that the -startMonitoringForRegion:desiredAccuracy: method is deprecated in iOS 6, so it shouldn't be used. Instead use -startMonitoringForRegion.
To know how to handle when your app is relaunched following a location event, see documentation here, that info as you will see is in the discussion of the deprecated method but it should still be relevant, I believe Apple forgot to migrate this information to the new method when they deprecated the old one. I've filed a bug to them about it.
UPDATE
Apple have updated the documentation of CLLocationManager following my bug report. Documentation now specifies for which types of location monitoring the app is or isn't launched after having been terminated. See Using Location Services in the Background
| 归档时间: |
|
| 查看次数: |
29392 次 |
| 最近记录: |