我正试图通过我的应用程序使用swift.how访问蓝牙设置可以访问蓝牙设置?
Xcode版本 - 8.0 swift - 2.3 iOS - 10
func openBluetooth(){
let url = URL(string: "App-Prefs:root=Bluetooth") //for bluetooth setting
let app = UIApplication.shared
app.openURL(url!)
}
Swift 3.0:适用于iOS 10
你将无法使用@Siddharth jain的解决方案。问题:Apple将拒绝该应用程序,并警告您不应再使用非公共API。否则,您可能冒着开发者计划的风险。
据我所知,您所能做的只是打开iPhone设置(或者如果有的话,可以开始使用您的应用程序设置。为此,您需要以下代码
guard let url = URL(string: UIApplication.openSettingsURLString) else {
// Handling errors that should not happen here
return
}
let app = UIApplication.shared
app.open(url)
这样,您将始终获得一个可以使用的URL,而不会有任何Apple审查问题。
到目前为止,您无法从iOS 10的应用程序访问蓝牙设置。您可以看到以下链接,让您的心灵平静。
https://forums.developer.apple.com/message/146658#146658 Opening the Settings app from another app