iPhone应用程序可以在后台为显著位置变化唤醒做的网络活动? [英] Can iphone app woken in background for significant location change do network activity?

查看:234
本文介绍了iPhone应用程序可以在后台为显著位置变化唤醒做的网络活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作是监视在后台显著位置变化的应用程序。我一直在阅读所有的答案(当然,我认为所有!)有关的iOS4和应用程序生命周期,但我不明白的是我是否能做到,当应用程序在后台唤醒任何网络接入作为显著位置变化的结果。

I'm working on an app that monitors significant location changes in the background. I've been reading all the answers (well, I think all!) about ios4 and the application lifecycle, but what I can't figure out is whether or not I can do any network access when the app is woken up in the background as a result of a significant location change.

该应用程序目前确实通过TCP套接字网络访问。套接字关闭时,应用程序将被暂停。

The app currently does network access via TCP sockets. The socket is shutdown when the app is suspended.

我可以重新连接插座,接收一些数据,发送新的位置,然后关闭所有的插座,同时仍然在后台接收位置改变事件的结果?这是很难测试固定在办公室时!我们可以假设,网络活动不到10秒的时间完成。此外,假设应用程序未注册为一个VOIP应用程序(可以/应该是什么?......)

Can I re-connect the socket, receive some data, send the new location and then shutdown the socket all while still in the background as a result of receiving the location change event? It's hard to test while stationary in the office! We can assume that the network activity takes less than 10 seconds to complete. Also assume the app isn't registered as a voip app (could/should it be? ...)

任何想法?

推荐答案

没错。您可以根据显著变化事件做你的网络处理。

Yep. You can do your network processing based on significant change events.

当你得到唤醒插入显著的变化(从终止或暂停状态)背景状态,你可以让你的HTTP请求。如果你发现你的应用程序被终止你完成你的HTTP请求之前,你可以要求通过<一个额外的后台处理时间href=\"http://developer.apple.com/library/ios/documentation/uikit/reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/beginBackgroundTaskWithExpirationHandler%3a\">beginBackgroundTaskWithExpirationHandler:方法上的UIApplication。

When you get woken up into the background state on significant change (from terminated or suspended state), you can make your http request. If you find your app is being terminated before you finish your HTTP request, you can ask for additional background processing time via the beginBackgroundTaskWithExpirationHandler: method on UIApplication.

我花了很短的火车旅行时间公平位测试了这一点。 :)

I spent a fair bit of time on short train trips to test this out. :)

这篇关于iPhone应用程序可以在后台为显著位置变化唤醒做的网络活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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