8

I done it for Bluetooth using the code on this link: Is there a way to toggle bluetooth and/or wifi on and off programmatically in iOS?

But I couldn't figure out how to do the same for Wifi. How do you switch the Wifi on/off? Is it possible?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Idan
  • 9,880
  • 10
  • 47
  • 76

3 Answers3

8

It's definitely not possible to turn WiFi off or on with any public (documented) API.

It might be possible to achieve this even on a non-jailbroken device using private functions.

See Apple80211Functions - there is a private function called Apple80211SetPower which is a good candidate for this job. But using it would be also interfering with automatic TX power settings - could result in either increased battery usage or decreased WiFi link quality (or both).

Of course your app would most definitely not pass App Store approval using this.

You can see how Apple80211 functions can be used if you download Stumbler source.

Stumbler SVN checkout is done by:

svn checkout http://iphone-wireless.googlecode.com/svn/trunk/ iphone-wireless-read-only

There are also two other projects that might help you start with low-level WiFi functions:

web-login-helper

BECHA

Fabian Tamp
  • 4,416
  • 2
  • 26
  • 42
Rok Jarc
  • 18,765
  • 9
  • 69
  • 124
  • Nice one. Thanks. I'm wondering if Apple ever thought of releasing this to public. But I think not. Let's see in the future. – nembleton Apr 20 '12 at 02:23
  • Can you please create a specific sample? I don't really understand if with that source I can control only the Wifi On/Off... – Idan Apr 23 '12 at 05:15
  • This function is not documented, so you're gonna need to do some experimenting. I'm just saying that this function is probably the best candidate for the job. – Rok Jarc Apr 23 '12 at 07:07
2

I'm fairly certain that the SDK does not allow access to turning Wifi on or off using the public framework, sorry. You could use a private framework but then you won't get your app past Apple, I suspect.

Ste
  • 1,136
  • 2
  • 10
  • 30
  • Yes. I am quite sure that non-jailbroken devices doesn't allow this. Simply because apple doesn't give control over the device to the devs through the SDK. Apple is the sole controller of the hardware and its settings. – nembleton Apr 19 '12 at 16:10
  • 1
    @nembleton/ @Ste: the guy above (user1071887) who asked this question related to WiFi says that he has done it programmatically to switch ON / OFF the bluetooth. And you mention in your answers that its not possible and Apple doesnt hand over the hardware control to the devs.. Can u fellas pls shed some more light and explain me. basically i wanna know if bluetooth doesn't consist of any hardware part or what?? thanks – taus-iDeveloper Apr 19 '12 at 16:41
  • Yeah you're right. But I think Apple considered Bluetooth as a "not major" part of the critical user experience they try to preserve. Don't get me wrong with my previous statement, but Apple is keeping most of its control on the device. – nembleton Apr 20 '12 at 02:04
  • I asked about how to do it with private functions. I know that it isn't public also the app is for my usage and not for the app store... – Idan Apr 23 '12 at 05:09
1

In iOs 2.x you can use some private API to do this, however it does not work in iOS4.x, 5.x. Hope that Apple will public the API for manage Wifi, now it is only used by Setting apple app.