IOS 11 / “Apps-prefs=root” function not working after update to Swift 3

我怕爱的太早我们不能终老 提交于 2019-12-06 05:52:37

问题


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:


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



来源:https://stackoverflow.com/questions/46487364/ios-11-apps-prefs-root-function-not-working-after-update-to-swift-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!