IOS 11 / “Apps-prefs=root” function not working af

2019-04-09 19:16发布

I'm quite new to Swift programming I've made a simple test application that open the settings programmatically, by a specific button.

Unfortunately after the update the button, instead of opening the desired setting page (the wifi page, in this case) open only the generic setting screen Could someone please help me understanding what exactly changed in swift 4, in order for me to fix this behaviour? Thansk a lot!

First code used - (i've either changed the iOS available to iOS 11.0, in order to match the deployment)

if let url = URL(string:"App-Prefs:root=WIFI") {
            if UIApplication.shared.canOpenURL(url) {
                if #available(iOS 10.0, *) {
                    UIApplication.shared.open(url, options: [:], completionHandler: nil)
                } else {
                    UIApplication.shared.openURL(url)
                }
            }
        }

second code used:

let url = URL(string: "App-Prefs:root=WIFI") 
UIApplication.shared.openURL(url!)

EDIT

Unfortunately the question raised is different from mine - i cannot anymore open the settings of the device, the other question ask how to open directly the settings of the APP

1条回答
我命由我不由天
2楼-- · 2019-04-09 19:42

Urls like App-Prefs:root are prohibited in App Store and using it causing app rejection.

If you want open app preferences you could use UIApplicationOpenSettingsURLString

查看更多
登录 后发表回答