我有一个简单的应用程序,可以UNNotification
定期发送用户。我想将一些字符串插入/粘贴到通知后面的应用程序中。
例如,如果用户在他的 iPhone 上使用Note 应用程序,当他收到我的通知时,我想在打开的 Note 中插入一些文本。
这可能吗?
这是我发送通知的代码:
let notification = UNMutableNotificationContent()
notification.sound = UNNotificationSound.default()
notification.subtitle = Message
notification.body = "Expand this notification for more options"
notification.categoryIdentifier = "Event"
let category = UNNotificationCategory(identifier: "Event",
actions: [],
intentIdentifiers: [],
options: [])
let notificationTrigger = UNCalendarNotificationTrigger(dateMatching: GenerateFireDate(), repeats: false)
let request = UNNotificationRequest(identifier: "Event",
content: notification,
trigger: notificationTrigger)
UNUserNotificationCenter.current().setNotificationCategories([category])
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
更新
我知道我有一个简单的解决方案,即Copy
在UIPasteboard
. 但我正在寻找一种替代方式,它比开放复制解决方案更方便。