I'm analyzing the feasibility of an app. Just a question:
when the app brings from active state to inactive state (slee开发者_C百科p or power button pressed) can I set a timer and request data using a remote http connection? I'm afraid that in inactive state the iOS closes all connections: there's a way to prevent this when in inactive state?
Thanks
**EDIT**
In the official documentation I've read this:
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.
This means that in Inactive state iOS can tear down my connection? Thanks
Unlike when going to background, your application continues to run as normal in the inactive state.
- (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.
*/
}
精彩评论