How to programmatically open the WIFI settings in

2019-01-25 11:22发布

The following code works fine on iOS 9, see this post. But it doesn't work on iOS 10. How to open WIFI settings programmatically on iOS 10

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];

7条回答
够拽才男人
2楼-- · 2019-01-25 12:04
 let url=URL(string: "App-Prefs:root=WIFI")
// you can change root as your requirements 
        if UIApplication.shared.canOpenURL(url!)
        {
            UIApplication.shared.open(url!, options: [:], completionHandler: {success in

            })

        }
        else{
            UIApplication.shared.open(url!, options: [:], completionHandler: {success in

            })
        }
查看更多
登录 后发表回答