From b8c934560c3a50f0e3fbadab1852bc9bf88c802c Mon Sep 17 00:00:00 2001 From: Hailey Date: Sun, 25 Aug 2024 11:47:45 -0700 Subject: [PATCH] add image save --- modules/BlueskyNSE/NotificationService.swift | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/BlueskyNSE/NotificationService.swift b/modules/BlueskyNSE/NotificationService.swift index 481402890f..fc6c0ee0c7 100644 --- a/modules/BlueskyNSE/NotificationService.swift +++ b/modules/BlueskyNSE/NotificationService.swift @@ -87,6 +87,9 @@ class NotificationService: UNNotificationServiceExtension { func mutateWithDmSound(_ content: UNMutableNotificationContent) { content.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "dm.aiff")) } + + func mutateWithAvatar(_ content: UNMutableNotificationContent) { + } } // NSEUtil's purpose is to create a shared instance of `UserDefaults` across @@ -102,4 +105,24 @@ private class NSEUtil { static func createCopy(_ content: UNNotificationContent) -> UNMutableNotificationContent? { return content.mutableCopy() as? UNMutableNotificationContent } -} + + static func saveImage(_ image: UIImage?) -> String? { + guard let image = image else { + return nil + } + + let dir = FileManager.default.temporaryDirectory + let filePath = "\(dir.absoluteString)\(ProcessInfo.processInfo.globallyUniqueString).png" + + guard let newUri = URL(string: filePath), + let pngData = image.pngData() else { + return nil + } + + do { + try pngData.write(to: newUri) + return filePath + } catch { + return nil + } + }}