Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public WritableArray processIntent() {
mediaTypesSupported.add("video");
mediaTypesSupported.add("audio");
mediaTypesSupported.add("image");
mediaTypesSupported.add("application");

String type = "";
String action = "";
Expand All @@ -67,8 +68,7 @@ public WritableArray processIntent() {
dataMap.putString("type", type);
dataMap.putString("value", intent.getStringExtra(Intent.EXTRA_TEXT));
dataArrayMap.pushMap(dataMap);
} else if (Intent.ACTION_SEND.equals(action) && (
mediaTypesSupported.contains(typePart))) {
} else if (Intent.ACTION_SEND.equals(action) && mediaTypesSupported.contains(typePart)) {
WritableMap dataMap = Arguments.createMap();
dataMap.putString("type", type);
Uri uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
Expand All @@ -82,6 +82,12 @@ public WritableArray processIntent() {
dataMap.putString("value", "file://" + RealPathUtil.getRealPathFromURI(currentActivity, uri));
dataArrayMap.pushMap(dataMap);
}
} else if (Intent.ACTION_VIEW.equals(action) && mediaTypesSupported.contains(typePart)) {
WritableMap dataMap = Arguments.createMap();
dataMap.putString("type", type);
Uri uri = intent.getData();
dataMap.putString("value", "file://" + RealPathUtil.getRealPathFromURI(currentActivity, uri));
dataArrayMap.pushMap(dataMap);
}
}
return dataArrayMap;
Expand Down

This file was deleted.

This file was deleted.

6 changes: 5 additions & 1 deletion ios/ReactNativeShareExtension.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ - (void)viewDidLoad {
completionHandler:nil];
}


RCT_EXPORT_METHOD(openURL:(NSString *)url) {
UIApplication *application = [UIApplication sharedApplication];
NSURL *urlToOpen = [NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[application openURL:urlToOpen options:@{} completionHandler: nil];
}

RCT_REMAP_METHOD(data,
resolver:(RCTPromiseResolveBlock)resolve
Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import { NativeModules } from 'react-native'
// NativeModules.ShareExtension.close()
export default {
data: () => NativeModules.ReactNativeShareExtension.data(),
close: () => NativeModules.ReactNativeShareExtension.close()
close: () => NativeModules.ReactNativeShareExtension.close(),
openURL: url => NativeModules.ReactNativeShareExtension.openURL(url),
}