简体   繁体   English

iOS 8中的定位服务:后台模式

[英]Location Services in iOS 8: Background Modes

There is a Background mode called Location Updates. 有一种称为位置更新的后台模式。

If I include the CoreLocation framework, and in my info.plist include the key NSLocationAlwaysUsageDescription and the value being a String with whatever I need to use it for, do I need to tick the background mode for Location Updates? 如果我包含CoreLocation框架,并且在我的info.plist中包含密钥NSLocationAlwaysUsageDescription ,并且值是一个String,我需要使用它,我是否需要勾选位置更新的后台模式? Can I just use it upon authorization? 我可以在授权时使用它吗? I've tried looking up iOS 8 guides for Core Location as I've never used it before, but nothing touches on this. 我已经尝试查找iOS 8的Core Location指南,因为我以前从未使用它,但没有触及这一点。 I don't know what it is used for if you don't have to tick it for getting location in the background. 我不知道它用于什么,如果你不必勾选它在后台获取位置。

When you get authorized for the AlwaysUsage, you can get location whenever your code is running. 当您获得AlwaysUsage的授权时,您可以在代码运行时获取位置。 But it won't run on background unless you have activated an appropriate mode for that. 但除非您已为此激活了适当的模式,否则它不会在后台运行。

Apple's Programming Guide describes the philosophy of background modes pretty well. Apple的编程指南很好地描述了背景模式的哲学。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM