在iOS 7或更高版本中关闭应用程序时,iOS是否可以执行操作?

在iOS 7或更高版本中关闭应用程序时,iOS是否可以执行操作?,ios,background,core-location,Ios,Background,Core Location,例如,找到位置并将其上载到服务器。 我需要在应用程序关闭时找到用户位置并将其上载到我的服务器。这可以在iOS 6.x及以下版本中完成 当应用程序首次后台运行时,调用UIApplication类的beginBackgroundTaskWithExpirationHandler方法 这将给你的应用程序额外10分钟的时间 在10分钟到期之前,使用startUpdatingLocation临时启用细粒度位置更新,然后使用beginBackgroundTaskWithExpirationHandler方法

例如,找到位置并将其上载到服务器。
我需要在应用程序关闭时找到用户位置并将其上载到我的服务器。

这可以在iOS 6.x及以下版本中完成

当应用程序首次后台运行时,调用UIApplication类的beginBackgroundTaskWithExpirationHandler方法

这将给你的应用程序额外10分钟的时间 在10分钟到期之前,使用startUpdatingLocation临时启用细粒度位置更新,然后使用beginBackgroundTaskWithExpirationHandler方法请求更多时间

临时启用位置更新会神奇地重置10分钟的背景宽限期。因此,该应用程序可以在“租约”到期前定期续订,并在后台无限期运行

以下是详细的演练: