后禁用allowBackgroundLocationUpdate

后禁用allowBackgroundLocationUpdate

本文介绍了启用后禁用allowBackgroundLocationUpdates(CLLocationManager)不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序可连续进行后台位置更新。
当然,它具有所有权限和其他内容,例如

My Application works with continuous background location updates.Of course it has all the permissions and other stuff like

allowsBackgroundLocationUpdates = true

最初,我想做出反应 LowPowerMode 更改在后台使用 NSProcessInfoPowerStateDidChange 通知。并禁用 allowsBackgroundLocationUpdates 停止更新位置,而无需调用 stopUpdatingLocation

Initially I wanted to react to LowPowerMode changes while in background using NSProcessInfoPowerStateDidChange notification. And to disable allowsBackgroundLocationUpdates to stop updating locations without calling stopUpdatingLocation.

但是,我发现收到通知并设置

However, I found out that after receiving the notification and setting

allowsBackgroundLocationUpdates = false

后台应用程序正在运行。

in background application is going on working.

所以我走得更远,发现,禁用 允许BackgroundLocationUpdates 甚至在前台设置为 true 根本不起作用。应用程序将继续在后台运行。

So I went farther and identified, that disabling allowsBackgroundLocationUpdates even in foreground after it was initially set to true doesn't work at all. Application continues working in background.

Apple对此事的文档

Apple's documentation on the matter






从CLLocationManager类中,对 allowsBackgroundLocationUpdates 属性

,显示了我提到的行为。

Simple project on GitHub that shows the behavior I mentioned.

那么问题是,该属性是否为故意行为?

So the question, is it intentional behavior of the property?

推荐答案

我认为属性讨论可以解决您的问题。

I think the property discussion can solve your problem.

这篇关于启用后禁用allowBackgroundLocationUpdates(CLLocationManager)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 12:24