1

I have seen that in ios 11 we can connect to wifi using SSID and a password. However, I'm trying to find out if we can disconnect from that network as well.

The requirement for my application is to connect to a specific wifi network using SSID, perform some operations, and then disconnect and connect again to previously connected network.

Thanks in advance.

JillevdW
  • 1,087
  • 1
  • 10
  • 21
Ghulam Rasool
  • 3,996
  • 2
  • 27
  • 40

3 Answers3

2

See the answer. It is discussed in detail here. Has solution for iOS 11

iOS - How to programmatically connect to a WiFi network given the SSID and Password using a private/3rd party library

Awais Fayyaz
  • 2,275
  • 1
  • 22
  • 45
0

Apps we build in Swift for iOS are sandbox, and as such we can not change system settings like this.

JillevdW
  • 1,087
  • 1
  • 10
  • 21
0

If you make the device connect to a specific wifi using NEHotspotConfigurationManager's apply(_:completionHandler:) method, you can make it disconnect again using removeConfiguration(forSSID:) in just a single line of code.

This does also remove the wifi from the device's list of known networks. But that's probably fine if your app put it there in the first place.

In most cases the iOS device should then connect to the previous network on its own. I don't think you can make it connect to a network whose password your app doesn't know.

jilipop
  • 53
  • 5