解散时未调用 UNNotificationCenterDelegate

UNNotificationCenterDelegate not called when dismissing

我有一个 AppleWatch 应用程序,它接收远程通知。在处理我的自定义操作 "a1" 和默认操作时,我在 notificationCenter(_:didRecieve response:...) 上收到回调。但是,自定义关闭操作不会调用此函数...

class ExtensionDelegate: NSObject, WKExtensionDelegate, UNUserNotificationCenterDelegate {

    func applicationDidFinishLaunching() {
        // Perform any final initialization of your application.
        UNUserNotificationCenter.current().delegate = self
        UNUserNotificationCenter.current().requestAuthorization(options: [UNAuthorizationOptions.alert, UNAuthorizationOptions.sound]) { (success, err) in

        }
        let a1 = UNNotificationAction(identifier: "a1", title: "Do Stuff", options: .foreground)
        let c1 = UNNotificationCategory(identifier: "c1", actions: [a1], intentIdentifiers: [], options: .customDismissAction)
        UNUserNotificationCenter.current().setNotificationCategories([c1])

            }
    }

    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
            print("Action Identifier: \(response.actionIdentifier)"
            completionHandler()
    }
}

所以我的代理人似乎可以工作,类别也可以...我错过了什么?

已解决此问题:如果您 运行 您的应用在 Watch 上并关闭它,您的 iOS 应用的 UNUserNotificationCenterDelegatenotificationCenter(_:didRecieve response:...)被称为(在我的例子中是 AppDelegate)! 可能是因为当你在手表上关闭它时,它到处都被关闭了......

虽然没有找到任何资源.. 如果你找到了, 请分享 link :)