Вопрос по objective-c, ios, iphone, ipad – CLLocationManager, пока приложение находится в фоновом состоянии


Мой вопрос: продолжает ли CLLocationManager работать, пока мое приложение неактивно?

Ваш Ответ

4   ответа

The Location Update background mode should NOT be used if you are just looking for significant change and region enter/exit events. You will still receive these events even if the background flag is NOT set, and you will save a lot of battery at the same time. If you do the above, you need to be mindful of limited permitted background time. If you don't take care to wrap up network requests etc. in the permitted time, you will network transaction failures. You should ONLY use the location background mode if you need to use detailed location tracking (e.g. -startUpdatingLocation), in which case this background mode will keep your app awake. Using the location background mode when not getting detailed location will piss off your users and may get your app rejected during the review process (depending on how you use location throughout your app). Your app may be killed at anytime by the OS if you do not have the background location mode set, so you will need to be sure to properly re-initialize your CLLocationManager instance in applicationDidFinishLaunching or applicationWillFinishLaunching in order to get the subsequent updateLocation or didEnter/ExitRegion delegate call. Just because location wakes up your app with a location update, it does NOT magically re-create your CLLocationManager without you programming it!

Надеюсь, это поможет!

Error: User Rate Limit ExceededCLLocationManagerDelegateError: User Rate Limit Exceeded

CLLocationManager сначала называетсяstartUpdatingLocation метод, а вAppName-Info.plist файл добавленRequired Background Modes -> App registers for location updates

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded Bojan
Error: User Rate Limit Exceeded Bojan

это возможно. У вас есть два варианта обработки событий службы определения местоположения, когда ваше приложение приостановлено, о чем можно прочитать в статье:Получение текущего местоположения пользователя. As noted:

There are two different services you can use to get the user’s current location:

The standard location service is a configurable, general-purpose solution and is supported in all versions of iOS. The significant-change location service offers a low-power location service for devices with cellular radios. This service is available only in iOS 4.0 and later and can also wake up an application that is suspended or not running.

Кроме того, как отмечено в нижней части этой статьи в разделе «Получение событий местоположения в фоновом режиме»:

If your application needs location updates delivered whether the application is in the foreground or background, there are multiple options for doing so. The preferred option is to use the significant location change service to wake your application at appropriate times to handle new events. However, if your application needs to use the standard location service, you can declare your application as needing background location services. An application should request background location services only if the absence of those services would impair its ability to operate. In addition, any application that requests background location services should use those services to provide a tangible benefit to the user. For example, a turn-by-turn navigation application would be a likely candidate for background location services because of its need to track the user’s position and report when it is time to make the next turn.

когда приложение находится в режиме фонового режима, вы просто не должны добавлять & quot; Приложение регистрирует обновления местоположения & quot; в & quot; Обязательные фоновые режимы & quot; ключ файла info.plist.

Я предлагаю по возможности использовать службу определения местоположения с существенными изменениями вместо стандартной службы определения местоположения, чтобы сохранить заряд батареи устройства.

Похожие вопросы