15585

Enable/Disable Wifi on non-jailbroken iOS device

Question:

This I needed for my internal app. I want to toggle wifi on ios device. Any framework is available. I tried following code, but it provides me no help. This doesn't change my wifi settings.

{ Class BluetoothManager = objc_getClass("BluetoothManager"); id btCont = [BluetoothManager sharedInstance]; [self performSelector:@selector(toggle:) withObject:btCont afterDelay:0.1f] ; } - (void)toggle:(id)btCont { BOOL currentState = [btCont enabled] ; [btCont setEnabled:!currentState] ; [btCont setPowered:!currentState] ; exit( EXIT_SUCCESS ) ; }

Answer1:

You're not going to be able to. iOS limits just how much third-party apps can interact with the underlying hardware. All applications written with the public SDK are sandboxed.

As 7KV7 says in <a href="https://stackoverflow.com/questions/5963880/turn-wifi-on-off-for-iphone-from-an-application/5963935#5963935" rel="nofollow">their answer here</a>:

<blockquote>

They only have access to the properties and data which Apple deems feasible to use within that sandbox. I am afraid Wi-fi doesn't come in the list.

</blockquote>

Answer2:

<h2>From Application</h2> notify_post("com.yourcompany.yourapp.yournotification"); <h2>From Dylib</h2> #import <objc/runtime.h> #import <SpringBoard/SBWiFiManager.h> HOOK(SpringBoard, applicationDidFinishLaunching$, void, id app) { //Listen for events via DARWIN NOTIFICATION CENTER CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &NotificationReceivedCallback, CFSTR("com.yourcompany.yourapp.yournotification"), NULL, CFNotificationSuspensionBehaviorCoalesce); } //THIS IS WHERE THE MAGIC HAPPENS static void NotificationReceivedCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { [[objc_getClass("SBWiFiManager") sharedInstance] setWiFiEnabled:NO]; } <h2>Note:</h2>

if you enounter any error on using Hook method you can refer this <a href="http://brandontreb.com/beginning-jailbroken-ios-development-your-first-tweak" rel="nofollow">link</a> it demonstrates how to hook init method found in SpringBoard to show a alert message when starting up the phone.

<h2>Warning:</h2>

You can not use this for appstore apps since private api is used.

<a href="https://stackoverflow.com/a/2152933/730807" rel="nofollow">Reference</a>

<a href="https://stackoverflow.com/users/171206/wrightscs" rel="nofollow">Attribtuion</a>

Hope this helps.

Recommend

  • Behaviour of exception handling in constructor of a class
  • How can I dynamically allocate 2D-array in one allocate C
  • Cant compile any opengl/freeglut/glut source code
  • Enable/Disable Wifi on non-jailbroken iOS device
  • ASM at&t syntax
  • Inter application communication in iphone
  • FastFormat on OS X
  • Using an iframe for sandboxing?
  • How to prevent context menu in an iframe?
  • Categories for NSMutableString and NSString causing binding confusion?
  • Passing multidimensional array in c90 (pre VLA-style)
  • Testing a python script in a specific version
  • adb device not listed for Gionee E7 mini
  • OpenOptionsMenu not working with ActionBarSherlock Custom SubMenu
  • How to create virtual printer with iOS Simulator?
  • How to create a Unix-domain socket with specific access permissions
  • back button function for phonegap windows phone 7
  • Can long-polling be achieved in Restlet by just making the thread sleep?
  • Retaining data after updating application
  • Facebook iOS SDK Not Calling Completion Handler
  • JSR-330 support in Picocontainer : @Inject … @Named(\"xxx)
  • GAE: Way to get reference to an HttpSession from its ID?
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Android application: how to use the camera and grab the image bytes?
  • How to revert to previous XCode version?
  • Insert new calendar with SyncAdapter- Calendar API Android
  • Ensure fsync did its job
  • How to get Eclipse Oxygen to run on Java 9
  • How to suppress a dialog
  • Hardware Accelerated Image Scaling in windows using C++
  • Custom Tabgroup Appcelerator
  • Moving mysql files across servers
  • Spray.io: When (not) to use non-blocking route handling?
  • Get object from AWS S3 as a stream
  • JavaScriptCore crash on iOS9
  • JTable with a ScrollPane misbehaving
  • unknown Exception android
  • How can i traverse a binary tree from right to left in java?
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?