Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open WIFI setting in Swift 3

I want to open WIFI setting section from my iOS application, my code was working well before Swift 3 with iOS 9.2

if let settingsURL = URL(string: AppSettingsWifiUrl) {
    UIApplication.shared.openURL(settingsURL)
}

But after updating it is not working with Xcode 8 + Swift 3 + iOS 10, can anybody help here?

like image 530
RJ168 Avatar asked Sep 29 '16 07:09

RJ168


1 Answers

We can't do this anymore on iOS 11, we can just open the settings :

if let url = URL(string:UIApplicationOpenSettingsURLString) {
    if UIApplication.shared.canOpenURL(url) {
       let url =  UIApplication.shared.open(url, options: [:], completionHandler: nil)
    }
}
like image 104
chawki Avatar answered Sep 21 '22 15:09

chawki