iphone - iOS:处于非事件状态时断开连接?

标签 iphone cocoa-touch ios background connection

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

当应用程序从事件状态进入非事件状态( sleep 或按下电源按钮)时,我可以设置计时器并使用远程 http 连接请求数据吗?恐怕在非事件状态下,iOS 会关闭所有连接:有没有办法在非事件状态下防止这种情况发生?

谢谢

**编辑**

In the official documentation我读过这篇文章:

Be prepared to handle connection failures in your network-based sockets. The system may tear down socket connections while your application is suspended for any number of reasons. As long as your socket-based code is prepared for other types of network failures, such as a lost signal or network transition, this should not lead to any unusual problems. When your application resumes, if it encounters a failure upon using a socket, simply reestablish the connection.

这意味着在非事件状态下,iOS 可以断开我的连接?谢谢

最佳答案

与进入后台时不同,您的应用程序在非事件状态下继续正常运行。

- (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.
     */
}

关于iphone - iOS:处于非事件状态时断开连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6056762/

相关文章:

iphone - Facebook API BUG?

objective-c - 使用numberWithFloat,但我想先将float修剪到1个小数位

objective-c - 如果我以编程方式在viewDidLoad中添加控件,如何从其他方法访问它?

ios - 如何在 Objective C 中添加循环搜索栏

ios - UIImageView 的深层复制没有复制 iOS 中应用于原始 View 的所有委托(delegate)和手势

iphone - 将 iPhone 通讯录联系人放入移动网络应用程序?

objective-c - CCLabelBMFont 由于缺少图像消息而崩溃

iphone - 添加手势识别器时 SWRevealViewController 为零

ios - "The archive passed validation with several warning"- 当我无法访问电子邮件时,我可以在哪里阅读它们?

iphone - MKAnnotationView - 锁定自定义注释 View 以固定位置更新