Search code examples
iosswiftwifi

Guide user to WiFi setting in iOS devices


I need to guide the user to the WiFi settings in their iOS device with a button to let them connect to WiFi manually. I searched for it and see that there was a method called prefs but many comment that it's not working now.

Can someone tell me how to link the user to WiFi settings or any other place in their iOS device with Swift?


Solution

  • Unfortunately, you can't.

    This used to be possible, but it was a bug in iOS 9 (which was fixed in iOS 10). It was never officially supported by Apple.

    If URL schemes do exist to do this, they're considered private API and if you use them, they may result in your app being rejected during review.

    You can open the settings app, that's documented and supported, but you aren't allowed to link to a specific area (such as wifi) within in it.

    To open settings:

    let application = UIApplication.shared
    if let url = URL(string: UIApplicationOpenSettingsURLString), application.canOpenURL(url)    {
        application.open(url, options: [:], completionHandler: nil)
    }
    

    There's a thread on Apple's developer forums where they confirm this:

    https://forums.developer.apple.com/thread/65007