开发者

How to trigger a WiFi connection on iPhone SDK 4.1

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 rea开发者_如何学JAVAsons.

How to trigger this from your app?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜