Wednesday, February 26, 2014

iOS closes the active Wi-Fi connection after 30 minutes


These days I’m involved developing an app (runs on both iPad and iPhone) that relies on Wi-Fi network a lot. I happen to notice that sometimes device looses its connection to the Wi-Fi network. Rest of the team was complaining that they have to keep on going to device settings to re-connect.

This behavior is because iOS closes the active Wi-Fi connection after 30 minutes of idling. In order to stop this behavior you need to tell iOS that your app requires Wi-Fi. You can do this by setting the property “Application uses Wi-Fi” to YES in your app’s info.plist file. Once set iOS will prompt for network selection when your app tries to connect to Wi-Fi while it is been temporary disabled by iOS. If Wi-Fi is switched off from the device settings this popup won’t appear. So I think it doesn’t force you to use Wi-Fi but prompts for network selection if Wi-Fi is switched on from device settings and the device is not connected to any network.

Also note that this is the same property you need to set if you need to prohibit the app from using Wi-Fi. In this case set “Application uses Wi-Fi” to NO.

No comments: