NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
@synchronized (session)
{
    [[session downloadTaskWithURL:attachmentURL
                completionHandler:^(NSURL *temporaryFileLocation, NSURLResponse *response, NSError *error) {
                    if (error != nil) {
                        NSLog(@"error.localizedDescription %@", error.localizedDescription);
                    } else {
                        NSFileManager *fileManager = [NSFileManager defaultManager];
                        NSURL *localURL = [NSURL fileURLWithPath:[temporaryFileLocation.path stringByAppendingString:fileExt]];
                        [fileManager moveItemAtURL:temporaryFileLocation toURL:localURL error:&error];
                        NSError *attachmentError = nil;
                        attachment = [UNNotificationAttachment attachmentWithIdentifier:@"" URL:localURL options:nil error:&attachmentError];
                        if (attachmentError) {
                            NSLog(@"attachmentError.localizedDescription %@", attachmentError.localizedDescription);
                        }
                    }
                    completionHandler(attachment);
                }] resume];
}
I am using FCM for push notification.
{
"to": "ffHjl2CblrI...",
"data": {
    "message": "Offer!",
    "image": "https://media.giphy.com/media/l4lR0Q5u91kTNJPsA/giphy.gif",
    "url": custom url,
    "mediaType": "gif",
    "type": "notification type"
},
"notification": {
    "body": "Body",
    "sound": "default",
    "title": "Title"
},
"content_available": true,
"mutable_content": true
}
This is my payload content.
I am using NotificationExtension above code which I am using to download data from push notification.
I got a success response from developer certificate. If I check with production certificate(update with previous one) I got error like this
__NSCFLocalDownloadFile: error 2 creating temp file: /private/var/mobile/Containers/Data/PluginKitPlugin/7D6B57B4-DC4D-4F3E-8113-C8469BA66BBB/tmp/CFNetworkDownload_NQQfGi.tmp
If I delete the app and run again it's working. But if I update version with new IPA it doesn't show the image in the notification.
What I miss, Is that certificate issue? Is app permission issue?
I am using separate APP ID (without push notification config) for UNNotificationServiceExtension.
Update
Also checked with APNS to that too not working.
Few more code and explanation about APNS and payload content
 
                        
I have encountered this error, which belongs to
PESIXErrorDomainand I'm pretty sure it's a iOS bug probably introduced in iOS 10 along with other bugs.The workaround I have implemented is to invalidate current session, start a new session and start a new download task with new session with acquired resume data.