如何在 iPhone SDK 4.1 上触发 WiFi 连接
有时,iOS 设备不会自动连接到可用的 WiFi,但如果启动 Safari 并尝试浏览到任何站点(或转到“设置”->“Wi-Fi”并选择所需的网络),它就会自动连接到可用的 WiFi。这可能是出于节省电池的原因。
如何从您的应用程序触发此操作?
Sometimes the iOS device will not connect to the available WiFi automatically, but it will if Safari is launched and try to browse to any site (or go to Settings->Wi-Fi and select the desired network). This is probably for battery savings reasons.
How to trigger this from your app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果需要,更高级别的 Cocoa Touch 网络 API 将尝试打开无线电。在此之前,它们会尽可能保持关闭状态以节省电池电量(在一定的超时后)。
Safari 可能使用高级 HTTP API 之一进行浏览。
The higher level Cocoa Touch network APIs will attempt to turn on the radios if needed. Until then they are kept off as much as possible to conserve battery power (after certain time-outs).
Safari probably uses one of the high level HTTP APIs for browsing.
您可以在 Info.plist 中尝试类似
UIRequiredDeviceCapability wifi
的内容。它实际上意味着“持久 wifi”(即即使显示器处于睡眠状态也保持 Wi-Fi 开启),但它也可能会触发重新连接。编辑:或者,
UIRequiredDeviceCapability wifi
。还有UIRequiresPersistentWiFi
,它的作用略有不同。You can try something like
<key>UIRequiredDeviceCapabilities</key><array><string>wifi</string></array>
in Info.plist. It actually means "persistent wifi" (i.e. keep Wi-Fi up even when the display is asleep), but it might also trigger a reconnection.EDIT: Alternatively,
<key>UIRequiredDeviceCapabilities</key><dict><key>wifi</key><true/></dict>
. There's also<key>UIRequiresPersistentWiFi</key><true/>
which does something slightly different.