从用户通知中打开设置 URL?
Open settings URL from user notification?
我可以从 UIAlertController 打开设置 URL,但不能从 UNUserNotificationCenter 通知打开。两种方法都使用相同的 URL 和相同的代码,即这个函数:
func open() {
if let url = self.url {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, completionHandler: { (success) in
Log.log("Opened settings url: \(url), \(success)", true)
})
}
}
}
我的日志记录行显示 completionHandler 在警报中被调用为 true,在通知中被调用为 false。起初我认为这可能是 phone 被锁定的问题,但我也通过在主屏幕上交互的通知得到了错误。
我需要做什么才能使它在通知中起作用?
尝试在声明 UNNotificationAction 时在选项中使用“.foreground”。
(此操作应导致应用程序在前台启动。)
我可以从 UIAlertController 打开设置 URL,但不能从 UNUserNotificationCenter 通知打开。两种方法都使用相同的 URL 和相同的代码,即这个函数:
func open() {
if let url = self.url {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, completionHandler: { (success) in
Log.log("Opened settings url: \(url), \(success)", true)
})
}
}
}
我的日志记录行显示 completionHandler 在警报中被调用为 true,在通知中被调用为 false。起初我认为这可能是 phone 被锁定的问题,但我也通过在主屏幕上交互的通知得到了错误。
我需要做什么才能使它在通知中起作用?
尝试在声明 UNNotificationAction 时在选项中使用“.foreground”。
(此操作应导致应用程序在前台启动。)