@@ -49,10 +49,10 @@ open class AUNotificationService: UNNotificationServiceExtension {
49
49
50
50
if let bestAttemptContent = bestAttemptContent {
51
51
// Modify the notification content
52
- guard let attachment = getImageAttachment ( request) else { return }
52
+ guard let mediaAttachment = getMediaAttachment ( request) else { return }
53
53
54
54
os_log ( . debug, " created attachment " )
55
- bestAttemptContent. attachments = [ attachment ]
55
+ bestAttemptContent. attachments = [ mediaAttachment ]
56
56
}
57
57
}
58
58
@@ -67,15 +67,15 @@ open class AUNotificationService: UNNotificationServiceExtension {
67
67
}
68
68
}
69
69
70
- private func getImageAttachment ( _ request: UNNotificationRequest ) -> UNNotificationAttachment ? {
70
+ private func getMediaAttachment ( _ request: UNNotificationRequest ) -> UNNotificationAttachment ? {
71
71
guard let payloadData = try ? payloadSchema. init ( decoding: request. content. userInfo) ,
72
- let mediaURLString = payloadData. remoteImageURL ,
72
+ let mediaURLString = payloadData. remoteMediaURL ,
73
73
let mediaType = mediaURLString. split ( separator: " . " ) . last,
74
74
let mediaURL = URL ( string: mediaURLString) ,
75
75
let mediaData = try ? self . loadDataFromURL ( mediaURL) else {
76
76
return nil
77
77
}
78
- os_log ( . debug, " got image data " )
78
+ os_log ( . debug, " got media data " )
79
79
80
80
let fileManager = FileManager . default
81
81
let temporaryFolderName = ProcessInfo . processInfo. globallyUniqueString
@@ -87,12 +87,11 @@ open class AUNotificationService: UNNotificationServiceExtension {
87
87
withIntermediateDirectories: true ,
88
88
attributes: nil )
89
89
90
- // supported image types: jpg, gif, png
91
- let imageFileIdentifier = " \( UUID ( ) . uuidString) . \( String ( mediaType) ) "
92
- let fileURL = temporaryFolderURL. appendingPathComponent ( imageFileIdentifier)
90
+ let mediaFileIdentifier = " \( UUID ( ) . uuidString) . \( String ( mediaType) ) "
91
+ let fileURL = temporaryFolderURL. appendingPathComponent ( mediaFileIdentifier)
93
92
try mediaData. write ( to: fileURL)
94
93
95
- return try UNNotificationAttachment ( identifier: imageFileIdentifier , url: fileURL)
94
+ return try UNNotificationAttachment ( identifier: mediaFileIdentifier , url: fileURL)
96
95
} catch {
97
96
return nil
98
97
}
0 commit comments