Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to turn off wifi or switch iPhone to offline mode in codes in swift 4?

I want to know is there any way to turn on or off the iPhone wifi or switch the device to offline mode in codes in swift 4 or not I know that apple may not allow the app can do such things to be distributed in App Store But it's Not important I just want to know is there any codes to do that or not (Just in swift 4)

like image 718
Saeed Rahmatolahi Avatar asked Jan 28 '23 17:01

Saeed Rahmatolahi


1 Answers

5 Solutions Collect From Internet About “How to turn off internet connection, bluetooth and WIFI programmatically?”

Ans

  • You can’t. Apple does not allow 3rd party apps to change global system settings like that.
  • There is no API available to control cellular data,wi-fi,bluetooth within in an app , User have to go to settings to enable or disable cellular data,wi-fi and bluetooth.
  • This is not possible in iOS unless you jailbroke your device. Apple is not allowing any apps developer to access wifi/bluetooth. You can only check wifi/tooth is connected or not.
  • You can’t do that using the iOS application. Apple not allowing it.
  • Legally there is no way to do it. Even somehow if you are manage to do it, Apple will reject your app while submitting to AppStore.

update

I am not sure the following code will work or not, try once, initially add the header file to your project folder and create the bridging header to your code ,then use the below code where you need , for ref purpose I taken the answer from here

var tempSBWifiManager: SBWiFiManager = objc_getClass("SBWiFiManager")
 // Steal a class from SpringBoard
 tempSBWifiManager.sharedInstance().isWiFiEnabled = false
like image 134
Anbu.Karthik Avatar answered Feb 04 '23 02:02

Anbu.Karthik