So the following code is being used to attach an image from local storage url of an image. I check in Terminal
to see if the image is stored and it does store the image without any issues. So ruling out any issues with the url itself.
do {
let attachment = try UNNotificationAttachment(identifier: imageTag, url: url, options: nil)
content.attachments = [attachment]
} catch {
print("The attachment was not loaded.")
}
Other code that goes with the creation of UserNotification works fine as it triggers at the correct specified time.
The code always goes to the catch block. Can anybody please point me to the mistake if there is any in the implementation. Please help. Thank you.
Edit: with print(error.localizedDescription)
error message is Invalid attachment file URL
.
Edit2 : with print(error)
error message is Error Domain=UNErrorDomain Code=100 "Invalid attachment file URL" UserInfo={NSLocalizedDescription=Invalid attachment file URL}
catch
statement? Add it to the question. – ImpressureInvalid attachment file URL
. I checked the URL and it is valid and am able to see the images being stored at the location using Terminal. – Unfrock