Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的 iPhone 应用程序通过 wifi 与远程服务器建立 TCP 连接。但是,如果一段时间内没有用户活动,设备会关闭 wifi 并断开连接。有可能预防吗?我需要在应用程序运行时保持连接。设置setIdleTimerDisabled:YES没有帮助 - 它可以防止屏幕关闭,但 wifi 仍然关闭。
您知道这是否可行以及如何实现?
查看此网址:http: //developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationEnvironment/ApplicationEnvironment.html#//apple_ref/doc/uid/TP40007072-CH7-SW59
表 1-3 Info.plist 文件中的重要键 UIRequiresPersistentWiFi: 一个布尔值,通知系统应用程序使用 Wi-Fi 网络进行通信。任何时间使用 Wi-Fi 的应用程序都必须将此键设置为 true;否则,30 分钟后,设备将关闭 Wi-Fi 连接以节省电量。设置此标志还可以让系统知道它应该在 Wi-Fi 可用但当前未使用时显示网络选择对话框。默认值为假。
表 1-3 Info.plist 文件中的重要键
UIRequiresPersistentWiFi:
一个布尔值,通知系统应用程序使用 Wi-Fi 网络进行通信。任何时间使用 Wi-Fi 的应用程序都必须将此键设置为 true;否则,30 分钟后,设备将关闭 Wi-Fi 连接以节省电量。设置此标志还可以让系统知道它应该在 Wi-Fi 可用但当前未使用时显示网络选择对话框。默认值为假。