1

I'm using the code snippet below, but it does not seem to open the Settings, it opens the Notifications settings of the app.

I need to open the wifi settings to enable the user to switch it off, iOS 12, Swift 4.2

{

    if response.actionIdentifier == "action1" {
        guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
            return
        }

        if UIApplication.shared.canOpenURL(settingsUrl) {
            UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
                print("Settings opened: \(success)") // Prints true
            })
        }
    }
}
shawn.t
  • 105
  • 1
  • 9
  • Have you tried this ? https://stackoverflow.com/a/34024467/5464805 – Olympiloutre Nov 13 '18 at 09:59
  • You can not open `Wifi-Settings` directly. Apple only allows to open settings. There are many [answers](https://stackoverflow.com/questions/39764553/how-to-open-wifi-setting-in-swift-3) to open `Wifi-settings` only but then your app will get rejection if the reviewer noticed this behavior. – Kamran Nov 13 '18 at 10:00
  • Possible duplicate of [How to open WIFI setting in Swift 3](https://stackoverflow.com/questions/39764553/how-to-open-wifi-setting-in-swift-3) – Kamran Nov 13 '18 at 10:01
  • I'm getting this when compiling the code with the suggested link [https://stackoverflow.com/questions/39764553/how-to-open-wifi-setting-in-swift-3]: `UIApplicationOpenSettingsURLString' has been renamed to 'UIApplication.openSettingsURLString` This opens "Allow AppName to access:" and not the General Settings Page – shawn.t Nov 13 '18 at 12:51
  • The method in the link opens the App's settings, not the phone's settings. How do I open the phone's settings? – shawn.t Nov 13 '18 at 13:08

1 Answers1

0

Open settings, don't open wifi setting. My app was rejected once when i opened wifi setting directly from my app. Avoid using private apis, apple may reject your app.

Viren Malhan
  • 115
  • 1
  • 5