【问题标题】:App-Prefs: root=NOTIFICATIONS_ID Not working on iOS 11 Swift 4App-Prefs:root=NOTIFICATIONS_ID 不适用于 iOS 11 Swift 4
【发布时间】:2018-04-18 01:20:03
【问题描述】:
我正在尝试使用:
UIApplication.shared.open(URL(string:"App-Prefs:root=NOTIFICATIONS_ID")!, options: [:], completionHandler: nil)
但它只是将我发送到“设置”应用,而不是“通知”选项卡。
我试过this 没有运气。
有什么办法吗?
【问题讨论】:
标签:
ios
notifications
ios11
swift4
【解决方案1】:
Apple 将拒绝您的应用提交。因为这是私有api。在下面使用下面的函数。参考:How do I open phone settings when a button is clicked?
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
})
}