Reputation: 4474
I am trying to open setting(wifi) form my application.
currently, I am using this code
let url = URL(string: "App-Prefs:root=WIFI") //for WIFI setting app
let app = UIApplication.shared
app.openURL(url!)
This code works for me, but when I use this code my application rejected by the app store.
Then I search code on the web I fount this code:-
if let url = URL(string: UIApplicationOpenSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
_ = UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
But this open app setting.
And I want to open either select wifi
screen or device setting
screen
Upvotes: 0
Views: 768
Reputation: 459
You can't use internal strings in order to open stuff, that's why your original code was rejected from the AppStore. Mainly, it's dangerous because those strings aren't documented and might change in the future without warning, breaking your application.
Sadly, you can't open any specific setting screen (you're only allowed to open your app settings), so you will have to stick to your new code (the one using UIApplicationOpenSettingsURLString
), or replace it with instructions to the user to open the WiFi settings in the device.
Upvotes: 1