From 15f08940b484d0d92c3915c477199145f8674422 Mon Sep 17 00:00:00 2001 From: Fin Date: Mon, 6 Jan 2025 16:55:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=8E=A8=E9=80=81=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=A4=8D=E5=88=B6=E5=85=A8=E9=83=A8=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bark/AppDelegate.swift | 6 +++++- .../NotificationViewController.swift | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Bark/AppDelegate.swift b/Bark/AppDelegate.swift index 394771f9..68119d80 100644 --- a/Bark/AppDelegate.swift +++ b/Bark/AppDelegate.swift @@ -155,6 +155,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD func presentController() { let alert = (userInfo["aps"] as? [String: Any])?["alert"] as? [String: Any] let title = alert?["title"] as? String + let subtitle = alert?["subtitle"] as? String let body = alert?["body"] as? String let url: URL? = { if let url = userInfo["url"] as? String { @@ -182,11 +183,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD if let title = title { shareContent += "\(title)\n" } + if let subtitle = subtitle { + shareContent += "\(subtitle)\n" + } if let body = body { shareContent += "\(body)\n" } for (key, value) in userInfo { - if ["aps", "title", "body", "url"].contains((key as? String) ?? "") { + if ["aps", "title", "subtitle", "body", "url"].contains((key as? String) ?? "") { continue } shareContent += "\(key): \(value) \n" diff --git a/notificationContentExtension/NotificationViewController.swift b/notificationContentExtension/NotificationViewController.swift index 38884533..f8303fbd 100644 --- a/notificationContentExtension/NotificationViewController.swift +++ b/notificationContentExtension/NotificationViewController.swift @@ -78,7 +78,21 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi if let copy = userInfo["copy"] as? String { UIPasteboard.general.string = copy } else { - UIPasteboard.general.string = response.notification.request.content.body + var content = "" + if !response.notification.request.content.title.isEmpty { + content += "\(response.notification.request.content.title)\n" + } + if !response.notification.request.content.subtitle.isEmpty { + content += "\(response.notification.request.content.subtitle)\n" + } + if !response.notification.request.content.body.isEmpty { + content += "\(response.notification.request.content.body)\n" + } + if let url = userInfo["url"] as? String, !url.isEmpty { + content += "\(url)\n" + } + content = content.trimmingCharacters(in: .whitespacesAndNewlines) + UIPasteboard.general.string = content } showTips(text: NSLocalizedString("Copy", comment: ""))