Below is a code that I use to share images within my "ShareViewController.m".
NSExtensionItem *item = [self.extensionContext.inputItems objectAtIndex:i];
NSItemProvider *itemProvider = item.attachments.firstObject;
if ([itemProvider hasItemConformingToTypeIdentifier:(NSString *)kUTTypeURL]) {
     [itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypeURL options:nil completionHandler:^(NSData *data, NSError *error) {
           NSLog(@"%@", data);
           // the rest of uploading script goes here
     }];
}
It all works fine if I share an image from WhatsApp. But it doesn't work if I want to share an image from Photo Library or from Facebook Messenger.
Does anyone know what the problem might be?
Thanks
 
    