简体   繁体   中英

Open Wifi Settings programatically from pop-up notification

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
            })
        }
    }
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM