菜鸟教程小白 发表于 2022-12-12 14:40:03

ios - 将应用程序保持在后台模式以持续更新位置


                                            <p><p>我的项目正在使用 CLLocationManager 对象,通过以下方式接收更新:
locationManager:didUpdateToLocations:</p>

<p>即使我的应用在后台,我也想要这些更新。因此,在 info.plist 中,我将“必需的后台模式”列表设置为应用程序寄存器以进行位置更新。</p>

<p>但我的测试表明它在后台状态下没有收到更新。 </p>

<p>但是,我不确定我对背景状态/暂停状态的理解是否正确。
这就是我认为它的工作原理:</p>

<pre><code>After the home button is pressed, the app enters background mode for 5 seconds,
and then enter suspended state.
</code></pre>

<p>我想这就是它不起作用的原因。但是如果将 info.plist 设置为 ""app registers for location updates"并不能阻止应用程序达到挂起状态,那么我该如何实现呢?</p>

<p>按主页按钮和按锁定按钮有什么区别(如果有)?我的意思是在国家层面。 </p>

<p>我已阅读本指南的相关部分:<a href="http://www.raywenderlich.com/29948/backgrounding-for-ios" rel="noreferrer noopener nofollow">http://www.raywenderlich.com/29948/backgrounding-for-ios</a> </p>

<p>我还是 IOS 新手,所以我可能忽略了一些东西。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>首先,您是否学习过 <a href="https://developer.apple.com/library/ios/documentation/userexperience/conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html" rel="noreferrer noopener nofollow">Location and Maps Programming Guide</a> 中的“在后台获取位置事件”? ?</p>

<p>您是否检查过 <code>backgroundRefreshStatus</code>?是否允许这个应用按照它在后台运行?</p>

<p><code>pausesLocationUpdatesAutomatically</code>的值是多少?</p>

<p>您要求的准确度是多少?您的移动是否足以在该精度上产生变化?</p>

<p>您是否调用 <code>startUpdatingLocation</code>?</p>

<p>这是 iOS 6 还是 7?如果是 iOS 7,请务必观看 Session 204:“What's New with Multitasking?”发生了一些变化,iOS 现在在关闭应用方面比以前更加积极。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 将应用程序保持在后台模式以持续更新位置,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/18925845/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/18925845/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 将应用程序保持在后台模式以持续更新位置