I have a Push Notification Service Extension, which is processing notification payload to attach image, if imageUrl
is key is present.
I use this simple code to perform the download:
let downloadTask = URLSession.shared.downloadTask(with: urlRequest) {
[weak self] tempURL, response, error in
/// parse results...
}
Notification payload contains "mutable-content" : 1
inside aps
. It's entirely randomly will it work or not.
When it doesn't work, I get this error
:
Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" UserInfo={NSErrorFailingURLStringKey=https://w7.pngwing.com/pngs/1005/607/png-transparent-african-elephant-animal-elephant-thumbnail.png, NSErrorFailingURLKey=https://w7.pngwing.com/pngs/1005/607/png-transparent-african-elephant-animal-elephant-thumbnail.png, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDownloadTask <4A847242-2314-4125-99E4-A424CF4B4B7C>.<7>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <4A847242-2314-4125-99E4-A424CF4B4B7C>.<7>}
I have no idea what Apple's internal code throws this error, what could possibly go wrong here.
This is happening for a while now, I just re-tested on iOS 17.5.1 on 14 Pro. App is compiled using Xcode 15.4 and Swift 5.10, latest SDK.
Not sure is it relevant but main iOS app has DataProtection capability set to Complete.