Hi Guys
When my app receive a push notification I use a UNNotificationServiceExtension to modify the notification content, download image from an url and add it as notification attachment
From iOS i can access to the attachment from this code
UNNotificationAttachment *attachment =content.attachments.firstObject;
if (attachment!=nil && [attachment.identifier isEqualToString:@"thumbFileURL"]) {
if ([attachment.URL startAccessingSecurityScopedResource]) {
self.immagine.image=[UIImage imageWithContentsOfFile:attachment.URL.path];
[attachment.URL stopAccessingSecurityScopedResource ];
}
}But on watchOS when i try to execute the same code the
startAccessingSecurityScopedResourcedoesn't start and i can't use the notification attachment !
UNNotificationAttachment * attachment =content.attachments.firstObject;
NSLog(@"attachment\n%@", attachment);
if (attachment!=nil && [attachment.identifier isEqualToString:@"thumbFileURL"]) {
if ([attachment.URL startAccessingSecurityScopedResource]) {
NSLog(@"can access to the attachment");
UIImage*attachmentImage=[UIImage imageWithContentsOfFile: attachment.URL.path]];
dispatch_async(dispatch_get_main_queue(), ^{
[self.immagineArticolo setImage:attachmentImage];
});
[attachment.URL stopAccessingSecurityScopedResource ]; }
else{
NSLog(@"can't access to the attachment");
}
} If i log the attachment i can read correctly all data (identifier,url,path,options etc etc), but i don't know how to display the image in the attachment !
Thank you in advanced and Happy Holiday !
P.S.: excuse me for my terrible english
Vanni