简体   繁体   English

即使应用终止,在iOS中实施定期位置更新

[英]Implementing Periodic Location Updates in iOS even if app gets terminated

My application requires periodic location updates (every 10 minutes). 我的应用程序需要定期进行位置更新(每10分钟更新一次)。 In foreground and background (app not terminated) the application is working correctly. 在前台和后台(应用程序未终止),应用程序正常运行。 But the problem starts to occur when the app is terminated by the user. 但是,当应用程序被用户终止时,问题开始出现。

I tried using this tutorial http://mobileoop.com/getting-location-updates-for-ios-7-and-8-when-the-app-is-killedterminatedsuspended . 我尝试使用本教程http://mobileoop.com/getting-location-updates-for-ios-7-and-8-when-the-app-is-killedterminatedsuspended
It works only when user's location is changing because of startMonitoringSignificantLocationChanges . 它仅在由于startMonitoringSignificantLocationChanges而更改用户位置时起作用 But I need locations in terminated state even if user is not changing its location. 但是,即使用户未更改位置,我也需要处于终止状态的位置。

Also, I have tried most of the stackoverflow questions but most of them gets satisfied with startMonitoringSignificantLocationChanges . 另外,我已经尝试了大多数stackoverflow问题,但其中大多数对startMonitoringSignificantLocationChanges感到满意。 But in my case it won't be enough to fulfil the application needs. 但就我而言,这还不足以满足应用程序的需求。

If a user terminates the app the system no longer grants it the same privileges. 如果用户终止了该应用程序,系统将不再授予其相同的特权。 Background fetch operations and background location will not get executed until the user decides to start up your app again. 除非用户决定再次启动您的应用程序,否则后台提取操作和后台位置将不会执行。 The system recognizes this a user choice to not have this app running in any way again. 系统认为这是用户选择,不再让该应用再次运行。

This isn't like the world of Android where an app can do as it pleases. 这与Android的世界并不一样,应用程序可以随心所欲。 Apple prefers user choice over what an app developer wants. 苹果公司更喜欢用户选择,而不是应用程序开发人员的需求。 This is of course good and bad as a developer. 作为开发人员,这当然是好事。 You need to provide the user with useful information about what your app is doing in the background so that they will allow it to run without terminating it. 您需要向用户提供有关您的应用程序在后台执行操作的有用信息,以便他们可以在不终止应用程序的情况下运行它。 If they do terminate it, there is nothing that you can do. 如果他们确实终止了它,那么您将无能为力。

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

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