Open radreamer opened 5 years ago
Hey, thanks for the great library
I need to support sharing for all file types and as a proof of concept, I modified ReactNativeShareExtension.m in the next way:
ReactNativeShareExtension.m
#define CONTENT_IDENTIFIER @"public.content"
extractDataFromContext
- (void)extractDataFromContext:(NSExtensionContext *)context withCallback:(void(^)(NSString *value, NSString* contentType, NSException *exception))callback { @try { NSExtensionItem *item = [context.inputItems firstObject]; NSArray *attachments = item.attachments; __block NSItemProvider *contentProvider = nil; [attachments enumerateObjectsUsingBlock:^(NSItemProvider *provider, NSUInteger idx, BOOL *stop) { if ([provider hasItemConformingToTypeIdentifier:CONTENT_IDENTIFIER]) { contentProvider = provider; *stop = YES; } }]; if (contentProvider) { [contentProvider loadItemForTypeIdentifier:CONTENT_IDENTIFIER options:nil completionHandler:^(id<NSSecureCoding> item, NSError *error) { NSURL *url = (NSURL *)item; if(callback) { callback([url absoluteString], @"text/plain", nil); } }]; } else { if(callback) { callback(nil, nil, [NSException exceptionWithName:@"Error" reason:@"couldn't find provider" userInfo:nil]); } } } @catch (NSException *exception) { if(callback) { callback(nil, nil, exception); } } }
After that looks like everything works well, but I am afraid that I can lose sight of some iOS restrictions as I`m not an Objective-C developer. Can you help with this and confirm or deny my thoughts?
@tallen11 Perhaps you might be able to help?
use react-native-file-share-intent
Hey, thanks for the great library
I need to support sharing for all file types and as a proof of concept, I modified
ReactNativeShareExtension.m
in the next way:#define CONTENT_IDENTIFIER @"public.content"
extractDataFromContext
:After that looks like everything works well, but I am afraid that I can lose sight of some iOS restrictions as I`m not an Objective-C developer. Can you help with this and confirm or deny my thoughts?