The image attached is just "Attachment-1", no extension. How do I specify one ?
NSData *compressedImage = UIImageJPEGRepresentation(self.resultImage, 0.8 );
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[ @"Check this out!", compressedImage ] applicationActivities:nil];
[self.navigationController presentViewController:activityViewController animated:YES completion:nil];
According to this answer you should be able to use this workaround to specify a filename
NSData *compressedImage = UIImageJPEGRepresentation(self.resultImage, 0.8 );
NSString *docsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *imagePath = [docsPath stringByAppendingPathComponent:@"image.jpg"];
NSURL *imageUrl = [NSURL fileURLWithPath:imagePath];
[compressedImage writeToURL:imageUrl atomically:YES]; // save the file
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[ @"Check this out!", imageUrl ] applicationActivities:nil];
The obvious drawback of this approach is that you will have to save the image on disk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With