简体   繁体   English

处于应用终止状态的位置更新网络服务

[英]Location update webservice in app terminated state

I want to just update location to server in app terminated state. 我只想在应用终止状态下更新服务器的位置。

I found one great example for getting location, when app is closed. 当应用关闭时,我找到了一个很好的位置定位示例。 here 这里

but what my problem is after getting location, somehow webservice not called. 但是我的问题是在获取位置之后,不以某种方式调用webservice。 any help would be great. 任何帮助都会很棒。

or any specific way for calling webservice in app termination state? 或在应用终止状态下调用Web服务的任何特定方式?

Once you get location updates in terminated state, you should call your web service in a single block. 一旦您获得处于终止状态的位置更新,就应该在一个单独的块中调用Web服务。

Try to move all your code that is required to perform the web service action. 尝试移动执行Web服务操作所需的所有代码。 Like, preparing data for web service, URLSession code and handling response, and everything to this single block. 例如,为Web服务准备数据,URLSession代码和处理响应,以及对单个块的所有操作。 If you have data to be taken from any global instance, you need to prepare them again in this block, as they are not available in app memory. 如果您要从任何全局实例中获取数据,则需要在此块中再次准备它们,因为它们在应用程序内存中不可用。

You should not refer any other class in that block. 您不应在该块中引用任何其他类。 They are not available for execution during terminated state. 它们在终止状态下不可执行。

Hope this helps :) 希望这可以帮助 :)

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

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