有没有办法在通知中心上修复本地通知,因此无法迅速清除

问题描述

我是新手,我想在通知中心修复通知,因此无法通过滑动或在通知中心单击清除将其删除。 我正在使用此代码来触发本地通知

 let content = UNMutableNotificationContent()
 content.title = Nsstring.localizedUserNotificationString(forKey: "Hello!",arguments: nil)
 content.body = Nsstring.localizedUserNotificationString(forKey: "Hello_message_body",arguments: nil)
 content.sound = UNNotificationSound.default
 content.categoryIdentifier = "notify-test"

 let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 1,repeats: false)
 let request = UNNotificationRequest.init(identifier: "notify-test",content: content,trigger: trigger)

 let center = UNUserNotificationCenter.current()
 center.add(request)

解决方法

用户始终可以清除通知。您无法避免。