'iOS Share Extension - Meta data for location is missing

I'm working on a share extension app for iOS and I need to record the creation date and location data from the asset. However it seems the file shared to us from system has location data stripped off of it. But I have noticed that when shared to app such as Facebook, they seem to have these data extracted from it (verified by their location suggestion when posting).

What I have done to verify is, when system provides the asset I have manually navigated to that location and added that photo or video back into photos library and sure enough, the location data is not present in that shared item. Is there a way I can request system to not strip these data when sharing to our app extension? How does the facebook app extract it?

Example on how I extracts data, printed log does not contain any gps section.

let data = NSData(contentsOf: url)!
let source = CGImageSourceCreateWithData(data as CFData, nil)!
let metadata = CGImageSourceCopyPropertiesAtIndex(source, 0, nil)!
print(metadata)

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source