应用关闭后如何处理UNNotificationAction?

Ada*_*aka 5 localnotification ios10 usernotifications

关闭应用程序(不在后台)时如何处理新的iOS10通知操作?

当应用最小化时,一切都可以正常使用:

UNUserNotificationCenter.current().delegate = x
Run Code Online (Sandbox Code Playgroud)

并处理它

class x: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Swift.Void) {
    }
}
Run Code Online (Sandbox Code Playgroud)

但是在应用程序关闭并且用户在通知中轻按操作时什么也没叫...也许我无法处理后台任务,而且我总是必须启动应用程序?

Ash*_*hah 2

是的,它总是启动应用程序,当用户点击通知中的操作时,按钮启动您的应用程序。苹果文档中的一些行:

点击按钮会启动您的应用程序(在前台或后台),并让您有机会执行指示的操作。您可以使用此类来指定按钮中显示的文本以及应用程序执行相应操作所需的信息。