I have created a share extension for my app to share images directly from photos app. However I also needs to fetch the metadata specifically location of the image shared. When sharing from the app I am able to fetch location from UIImagePickerController but when using share extension I am just getting the UIImage object, not the dictionary. Is there a way I can get the location for images shared from extension as well?
Here is my code:
- (void)didSelectPost {
for (int i=0; i<self.extensionContext.inputItems.count; i++) {
NSExtensionItem *item = self.extensionContext.inputItems[i];
for (int j=0; j<item.attachments.count; j++) {
NSItemProvider *itemProvider = item.attachments[j];
if ([itemProvider hasItemConformingToTypeIdentifier: (NSString *)kUTTypeImage]) {
[itemProvider loadItemForTypeIdentifier: (NSString *)kUTTypeImage options: nil completionHandler: ^(NSData* image, NSError* error) {
[self newSighting:image location:nil isSevere:false];
[self.extensionContext completeRequestReturningItems:@[] completionHandler:nil];
}];
}
}
}
}