[英]How to keep iOS app alive while in background, longer than 10 minutes?
I found this tutorial https://www.raywenderlich.com/5247-core-location-tutorial-for-ios-tracking-visited-locations (you can download the sample project and play with it.) which will track you by giving you long/lat, even if the app is closed or backgrounded, it will continue to give you the lat/long.我找到了本教程https://www.raywenderlich.com/5247-core-location-tutorial-for-ios-tracking-visited-locations (您可以下载示例项目并使用它。)它将通过提供跟踪您你的纬度/纬度,即使应用程序关闭或后台运行,它也会继续为你提供纬度/经度。 However, if the app is backgrounded, and I leave the phone alone for about 10 minutes, the app seems to go into some kind of "suspend" state, in which when I pick it up again, the app no longer track you (no lat/long) until you bring the app to the foreground(you can now see the UI), then it will resume tracking.
但是,如果应用程序在后台运行,并且我将手机搁置约 10 分钟,应用程序似乎 go 进入某种“暂停”state,其中当我再次拿起它时,应用程序不再跟踪您(没有纬度/经度),直到您将应用程序带到前台(您现在可以看到 UI),然后它将恢复跟踪。 But I want this app to continue tracking, while in the background indefinitely.
但我希望这个应用程序在无限期地在后台继续跟踪。 I don't want it to go into a suspend mode.
我不想让它 go 进入挂起模式。
For testing purposes, I made the code:出于测试目的,我编写了代码:
locationManager.distanceFilter = 3 // give me lat/long every 3 meters
I tried a lot of things to get this to work, for example, I created a recursive function that will run indefinitely, just to keep the app alive.我尝试了很多方法来让它工作,例如,我创建了一个递归 function 将无限期地运行,只是为了让应用程序保持活力。 But it did not work
但它没有用
When application enters the "Background" state - you code still running, but after several minutes app move to "Suspended" state and system can kill application for free memory, in this state you code doesn't work When application enters the "Background" state - you code still running, but after several minutes app move to "Suspended" state and system can kill application for free memory, in this state you code doesn't work
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.