【发布时间】:2018-08-07 07:33:56
【问题描述】:
如何以编程方式在设备通知设置中打开 iOS 应用通知切换(开/关)屏幕?
我检查了UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!),但它只打开应用程序根设置,而不是通知子部分。
【问题讨论】:
标签: swift notifications setting
如何以编程方式在设备通知设置中打开 iOS 应用通知切换(开/关)屏幕?
我检查了UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!),但它只打开应用程序根设置,而不是通知子部分。
【问题讨论】:
标签: swift notifications setting
您无法打开子部分。使用它,您只能导航到应用程序的设置。
if let appSettings = URL(string: UIApplicationOpenSettingsURLString + Bundle.main.bundleIdentifier!) {
if UIApplication.shared.canOpenURL(appSettings) {
UIApplication.shared.open(appSettings)
}
}
【讨论】:
恐怕不可能以可靠的方式。
你可以试试:
UIApplication.shared.open(URL(string:"App-Prefs:root=NOTIFICATIONS_ID")!, options: [:], completionHandler: nil)
如此处所述:https://stackoverflow.com/a/49041704/5226328 但它可以被 Apple 拒绝。
【讨论】: