Getting the Attachment Content from UNNotificationAttachment

Hi!

I'm using Firebase to handle push notifications.

For each notification received, I create a NotificationItem struct which gets saved to the cache (the app's document folder) in an array of NotificationItems.

I also send images through Firebase's Notification Composer and in App Delegate I retrieve them by accessing the attachment like this:

if let attachmentURL = notification.request.content.attachments.first.url

The url retrieved is like this: file:///var/mobile/Library/UserNotifications/6FA[...]B84E9F7/Attachments/527[...]fc.jpeg

Finally, in the table view controller with the list of all the notification items, I'm trying to set the UIImageView's image like this:

if let imageURL = notificationItem.attachmentURL {
    cell.imageView?.image = UIImage(contentsOfFile: imageURL.path)
}

But when I run it, it's blank and no image gets loaded.

My question is: how should I load the file into an UIImage?

If I'm not mistaken the act of downloading the image is all handled by Firebase, by using a notification service extension and by populating the notification content with this line of code: FIRMessagingExtensionHelper().populateNotificationContent(bestAttemptContent, withContentHandler: contentHandler). So I'm left with the act of loading the image file into an UIImage.