我正在使用 UNNotificationContentExtension 并试图找出如何在我的视图中添加按钮并在我的扩展类中为该按钮设置IBAction?

请参阅附件图片:

enter image description here

正如你所看到的,我已经为 UNNotificationContentExtension 类添加了两个按钮,但永远不会被调用?

这是我在我的app委托中设置通知的方法:

func application(_ application:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey:Any]?) - > Bool {

let center = UNUserNotificationCenter.current()
let options: UNAuthorizationOptions = [.alert]

center.requestAuthorization(options: options) { (authorized, error) in
    if authorized {
        let categoryId = "com.tutplus.Custom-Notification-Interface.notification"

        let category = UNNotificationCategory(identifier: categoryId, actions: [], intentIdentifiers: [], options: [])
        center.setNotificationCategories([category])

        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 30, repeats: false)
        let content = UNMutableNotificationContent()
        content.categoryIdentifier = categoryId
        content.title = "Notification Title"
        content.subtitle = "Notification Subtitle"
        content.body = "Notification body text"
        content.userInfo = ["customNumber": 100]

        let request = UNNotificationRequest(identifier: "exampleNotification", content: content, trigger: trigger)
        center.add(request, withCompletionHandler: nil)
    }
}

return true

}

I don't want to add these to UNNotificationAction like this way

let ok = UNNotificationAction(identifier: "OKIdentifier",
                              title: "Turn off", options: [.destructive])

我需要在视图中有按钮并相应地对它们做出反应 . 我很感激,如果有人可以帮助我 .