alinz / react-native-share-extension

react-native as an engine to drive share extension
MIT License
762 stars 396 forks source link

iOS Video cant share #122

Closed jebinwinfy closed 5 years ago

jebinwinfy commented 5 years ago

Cant share video file through this! If I set 'NSExtensionActivationRule' with 'NSExtensionActivationSupportsMovieWithMaxCount', can't get video url, anybody know this issue???

AndrewHenderson commented 5 years ago

@jebinwinfy The sharing capabilities are currently limited to string/url/image. See: https://github.com/alinz/react-native-share-extension/blob/master/ios/ReactNativeShareExtension.m#L81-L89

This would be a nice feature addition, if you want to submit a PR 😄

jebinwinfy commented 5 years ago

I made it with the following,

update "ReactNativeShareExtension.m" file and it will give you thumbnail of video.

import "ReactNativeShareExtension.h"

import "React/RCTRootView.h"

import <MobileCoreServices/MobileCoreServices.h>

import <AVFoundation/AVFoundation.h>

define URL_IDENTIFIER @"public.url"

define IMAGE_IDENTIFIER @"public.image"

define TEXT_IDENTIFIER (NSString *)kUTTypePlainText

define VIDEO_IDENTIFIER_MPEG_4 @"public.mpeg-4"

define VIDEO_IDENTIFIER_QUICK_TIME_MOVIE @"com.apple.quicktime-movie"

NSString *VideoIdentifier;

NSExtensionContext* extensionContext;

@implementation ReactNativeShareExtension { NSTimer autoTimer; NSString type; NSString* value; }

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(close) { [extensionContext completeRequestReturningItems:nil completionHandler:nil]; }

RCT_REMAP_METHOD(data, resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { [self extractDataFromContext: extensionContext withCallback:^(NSString val, NSString contentType, NSString thumbnailBase64, NSException err) { if(err) { reject(@"error", err.description, nil); } else { resolve(@{ @"type": contentType, @"value": val, @"thumbnailBase64": thumbnailBase64 }); } }]; }

@end