如何以编程方式在iOS 11中打开蓝牙设置

Mak*_*zev 5 settings bluetooth swift3 swift4 ios11

我用于iOS 10的代码不再适用于iOS 11 ...任何想法要改变什么?我需要打开蓝牙设置,而不是通过以下代码打开的常规iOS设置

if let settings = URL(string: "App-Prefs:root=Bluetooth") {
        UIApplication.shared.open(settings, options:[:], completionHandler:nil)
}
Run Code Online (Sandbox Code Playgroud)

Rac*_*wal 0

从 iOS 11 开始,Apple 建议使用公共 API 或使用私有实体 \xe2\x80\x9cprefs:root" 或 "App-Prefs:root" URL 方案删除该功能。

\n\n

因此,如果您使用上述 url 方案,您的应用程序可能会被拒绝。如果您想打开应用程序设置,请使用UIApplicationOpenSettingsURLString

\n