通过弹出通知以程序方式打开Wifi设置



我使用下面的代码片段,但它似乎没有打开设置,而是打开了应用程序的通知设置。

我需要打开wifi设置,让用户关闭它,iOS 12,Swift 4.2

{
if response.actionIdentifier == "action1" {
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
return
}
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: (success)") // Prints true
})
}
}
}

打开设置,不要打开wifi设置。当我直接从应用程序打开wifi设置时,我的应用程序被拒绝了一次。避免使用私人api,苹果可能会拒绝您的应用程序。

最新更新