Replyable message notification (w.i.p)

This commit is contained in:
2024-12-21 17:15:14 +08:00
parent dc78f39969
commit eb125fc436
5 changed files with 59 additions and 15 deletions

View File

@ -61,6 +61,22 @@ class NotificationService: UNNotificationServiceExtension {
guard let avatarIdentifier = metadata["avatar"] as? String else {
throw ParseNotificationPayloadError.missingAvatarUrl("The notification has no avatar.")
}
let replyableMessageCategory = UNNotificationCategory(
identifier: content.categoryIdentifier,
actions: [
UNTextInputNotificationAction(
identifier: "reply_action",
title: "Reply",
options: []
),
],
intentIdentifiers: [],
options: []
)
UNUserNotificationCenter.current().setNotificationCategories([replyableMessageCategory])
content.categoryIdentifier = replyableMessageCategory.identifier
let metadataCopy = metadata as? [String: String] ?? [:]
let avatarUrl = getAttachmentUrl(for: avatarIdentifier)