Using the
MFMailComposeViewController
and attaching an image with GPS coords (taken on the iOS device with camera) like:
UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData* data = UIImageJPEGRepresentation(image, 1.0);
[self.mailer addAttachmentData:data mimeType:@"image/jpeg" fileName:@"testimagesent.jpg"];
is not "including" the GPS data with the email send.
But, if the same file is sent using the iOS email application the GPS information is being sent.
Any clue on why this is happening and / or a way to fix this, setting on the MFMail, ???
[Addition]
After playing around with this a bit, if the image is part of the main bundle of the app, the metadata is included with the image on the email attachment.
NSString *photoFilePath = [[NSBundle mainBundle] pathForResource:@"testimage" ofType:@"jpg"];
NSData *data = [NSData dataWithContentsOfFile:photoFilePath];
[self.mailer addAttachmentData:data mimeType:@"image/jpeg" fileName:@"testimagesent.jpg"];
If the image is not part of the main bundle (from photopicker, etc) the data is not part of the attachment.
Will be playing arounds a bit, but this is looking like some sort of Apple privacy issue on sending a photo via an application email?
[Addition2]
It looks like it is boiling down to the statement
CGImageDestinationAddImageFromSource(destination,source,0, (__bridge CFDictionaryRef) metadataAsMutable);
Is not adding the metadata if the image is from the library. This is strange and not accepted 100%, but the code looks good and is adding / changing for a bundled image file.