即使应用程序被终止,也会在iOS中实现定期位置更新 [英] Implementing Periodic Location Updates in iOS even if app gets terminated

查看:112
本文介绍了即使应用程序被终止,也会在iOS中实现定期位置更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要定期更新位置(每10分钟一次)。在前台和后台(应用程序未终止)应用程序正常工作。但是当用户终止应用程序时,问题就开始发生了。

My application requires periodic location updates (every 10 minutes). 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.

我尝试使用本教程 http://mobileoop.com/getting-location-updates-for-ios-7-and-8-when-the-app-is-killedterminatedsuspended

仅当用户位置因 startMonitoringSignificantLocationChanges 而发生变化时才有效。但即使用户没有更改其位置,我也需要处于已终止状态的位置。

I tried using this tutorial 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. But I need locations in terminated state even if user is not changing its location.

此外,我已尝试过大多数stackoverflow问题,但大多数人对 startMonitoringSignificantLocationChanges 感到满意。但在我的情况下,它不足以满足应用程序的需求。

Also, I have tried most of the stackoverflow questions but most of them gets satisfied with 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.

这与应用程序可以随心所欲的Android世界不同。 Apple倾向于用户选择应用程序开发人员想要的内容。作为开发人员,这当然是好事和坏事。您需要向用户提供有关您的应用在后台执行的操作的有用信息,以便他们可以在不终止操作的情况下运行该应用。如果他们确实终止它,那么你无能为力。

This isn't like the world of Android where an app can do as it pleases. 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.

这篇关于即使应用程序被终止,也会在iOS中实现定期位置更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆