iOS:处于非活动状态时断开连接?

时间:2011-05-19 09:47:31

标签: iphone cocoa-touch ios background connection

我正在分析应用程序的可行性。只是一个问题:

当应用程序从活动状态进入非活动状态(按下睡眠或电源按钮)时,我可以设置定时器并使用远程http连接请求数据吗?我担心在非活动状态下iOS会关闭所有连接:有一种方法可以在处于非活动状态时阻止它吗?

由于

**编辑**

In the official documentation我读过这个:

  

准备好处理连接   基于网络的故障   插座即可。系统可能会拆除   你的套接字连接   申请暂停任何   原因多少。只要你的   基于套接字的代码准备好了   其他类型的网络故障,例如   作为丢失的信号或网络   转型,这不应该导致   任何异常问题。当你的   应用程序恢复,如果它遇到   简单地说,使用套接字失败了   重建连接。

这意味着在非活动状态下iOS可以拆除我的连接?感谢

1 个答案:

答案 0 :(得分:1)

与转到后台时不同,您的应用程序将继续在非活动状态下正常运行。

- (void)applicationWillResignActive:(UIApplication *)application {
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}
相关问题