Howto programmatically turn on/off WiFi and Bluetooth?
Is there a programmatic way to turn on and off the WiFi and Bluetooth networks on the iPhone? I'm looking for the same functionality that Settings/[General/Bluetooth],WiFi/OnOff provides.
Is there a programmatic way to turn on and off the WiFi and Bluetooth networks on the iPhone? I'm looking for the same functionality that Settings/[General/Bluetooth],WiFi/OnOff provides.
There isn't a way using the APIs provided by the SDK. It's trivial to do if you use private frameworks, but if you use private frameworks, you will be in violation of Apple's SDK license agreement.
I've already written such an app for my own purposes (toggling Bluetooth on and off), but for obvious reasons I can't distribute it. Details can be found here if you are interested:
I'm interested about this:
in the PhotoShare application, if the bluetooth is deactived, automatically is activated...
so... how did you think that PhotoShare works??
Yep - the issue is private frameworks. Which means Apple will most definitely reject the app.
There are alternatives, however. The Jailbreak Community can always make use of apps like that. However, from what I've been seeing of late, the "Jailbreak Community" is dying off pretty fast, as a lot of the devs for it are either moving to the App Store, or simply charging obscene prices for once free apps. They either handle their records poorly, or simply don't care, and as a result many "buyers" of their apps have been completely screwed over. ZodTTD, I'm looking at you.
Thanks for the link but I was wondering actually how to do it (frameworks to import, maybe even some code).
You're going to find a hard time finding that code here, I would suggest you try searching through some cydia apps source code such as Bossprefs or Customize. You can also try searching through the "System" commands that the iPhone utilizes. For example:
This might not be useful to you, but I believe that if you use a GKPeerPicker to connect two iPhones together, it will automatically request that the user enable Bluetooth and provide a dialog box to do so. This isn't much use if, like me, you're making an app that needs to connect multiple clients to a single host.
Not sure if it helps, but there's a key that you can put into the application .plist called 'App requires Wifi' or something similar that I think should ensure that WiFi is available. Sadly it doesn't do the same for Bluetooth.