I am using AvFoundation to take still image and adding gps info to metadata and saving to a photo album using Asset library but gps info is not saving at all.
here
I had exactly the same problem. I think the documentation on this topic isn't great, so I solved it in the end by looking at the metadata of a photo taken by the Camera app and trying to replicate it.
Here's a run down of the properties the Camera app saves:
If you stick to these you should be fine. Here's a sample:
CFDictionaryRef metaDict = CMCopyDictionaryOfAttachments(NULL, imageDataSampleBuffer, kCMAttachmentMode_ShouldPropagate);
CFMutableDictionaryRef mutable = CFDictionaryCreateMutableCopy(NULL, 0, metaDict);
NSDictionary *gpsDict = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:self.currentLocation.coordinate.latitude], kCGImagePropertyGPSLatitude,
@"N", kCGImagePropertyGPSLatitudeRef,
[NSNumber numberWithFloat:self.currentLocation.coordinate.longitude], kCGImagePropertyGPSLongitude,
@"E", kCGImagePropertyGPSLongitudeRef,
@"04:30:51.71", kCGImagePropertyGPSTimeStamp,
nil];
CFDictionarySetValue(mutable, kCGImagePropertyGPSDictionary, gpsDict);
// Get the image
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
// Get the assets library
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:[image CGImage] metadata:mutable completionBlock:captureComplete];
This is all in the completionHandler of the captureStillImageAsynchronouslyFromConnection method of your AVCaptureConnection object, and self.currentLocation is just a CLLocation. I hardcoded the timestamp and Lat/Lng Refs for the example to keep things simple.
Hope this helps!