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 use 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 helpful content.
I am using NotificationExtension above the code that I use to load data from push notifications.
I received a successful response from a developer certificate. If I check with a production certificate (update with the previous one), I received an error similar to this
__NSCFLocalDownloadFile: error 2 creating temp file: /private/var/mobile/Containers/Data/PluginKitPlugin/7D6B57B4-DC4D-4F3E-8113-C8469BA66BBB/tmp/CFNetworkDownload_NQQfGi.tmp
If I uninstall the application and run it again. But if I update the version with a new IPA, it does not display the image in the notification.
What did I miss, is it a certificate issue? Problem with permission to use the application?
I use a separate APP identifier (without push notification configuration) for UNNotificationServiceExtension .
Update
Also checked using APNS , which also does not work.
A bit more code and explanations about APNS and payload content