gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 05:04:05 24 4
gpt4 key购买 nike

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

当应用程序从事件状态进入非事件状态( 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com