本文介绍了Swift 4中的代码是否可以关闭wifi或将iPhone切换为离线模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何方法可以打开或关闭iPhone wifi或以快速4的代码将设备切换到离线模式我知道苹果可能不允许该应用执行可以在App Store中分发的事情,但这并不重要,我只想知道是否有任何代码可以做到这一点(仅在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)

推荐答案

答案

  • 您不能. Apple不允许第三方应用程序那样更改全局系统设置.
  • 在应用程序中没有API可用于控制蜂窝数据,wi-fi,蓝牙.用户必须进入设置以启用或禁用蜂窝数据,wi-fi和蓝牙.
  • 除非您越狱了设备,否则这在iOS中是不可能的.苹果不允许任何应用程序开发人员访问wifi/蓝牙.您只能检查wifi/牙齿是否已连接.
  • 您无法使用iOS应用程序执行此操作.苹果不允许.
  • 从法律上讲,这是没有办法的.即使您设法做到了,Apple也会在提交到AppStore时拒绝您的应用程序.

更新

我不确定以下代码能否正常工作,请尝试一次,首先添加头文件到您的项目文件夹,并在您的代码中创建桥接头,然后在需要的地方使用以下代码,出于参考目的,我从

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

这篇关于Swift 4中的代码是否可以关闭wifi或将iPhone切换为离线模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 16:10