diff --git a/Examples/UIExplorer/ActionSheetIOSExample.js b/Examples/UIExplorer/ActionSheetIOSExample.js
index ccc86fba4..31fd79c38 100644
--- a/Examples/UIExplorer/ActionSheetIOSExample.js
+++ b/Examples/UIExplorer/ActionSheetIOSExample.js
@@ -98,7 +98,6 @@ var ActionSheetTintExample = React.createClass({
}
});
-
var ShareActionSheetExample = React.createClass({
getInitialState() {
return {
@@ -121,7 +120,7 @@ var ShareActionSheetExample = React.createClass({
showShareActionSheet() {
ActionSheetIOS.showShareActionSheetWithOptions({
- url: 'https://code.facebook.com',
+ url: this.props.url,
message: 'message to go with the shared url',
subject: 'a subject to go in the email heading',
excludedActivityTypes: [
@@ -163,6 +162,14 @@ exports.examples = [
},
{
title: 'Show Share Action Sheet',
- render(): ReactElement { return ; }
+ render(): ReactElement {
+ return ;
+ }
+ },
+ {
+ title: 'Share Local Image',
+ render(): ReactElement {
+ return ;
+ }
}
];
diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js
index c63618441..9570d2b8c 100644
--- a/Libraries/ActionSheetIOS/ActionSheetIOS.js
+++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js
@@ -31,7 +31,18 @@ var ActionSheetIOS = {
callback
);
},
-
+
+ /**
+ * Display the iOS share sheet. The `options` object should contain
+ * one or both of:
+ *
+ * - `message` (string) - a message to share
+ * - `url` (string) - a URL to share
+ *
+ * NOTE: if `url` points to a local file, or is a base64-encoded
+ * uri, the file it points to will be loaded and shared directly.
+ * In this way, you can share images, videos, PDF files, etc.
+ */
showShareActionSheetWithOptions(
options: Object,
failureCallback: Function,
diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/Libraries/ActionSheetIOS/RCTActionSheetManager.m
index ab1a8c8d0..18fc8596b 100644
--- a/Libraries/ActionSheetIOS/RCTActionSheetManager.m
+++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.m
@@ -156,14 +156,26 @@ RCT_EXPORT_METHOD(showShareActionSheetWithOptions:(NSDictionary *)options
return;
}
- NSMutableArray *items = [NSMutableArray array];
+ NSMutableArray *items = [NSMutableArray array];
NSString *message = [RCTConvert NSString:options[@"message"]];
if (message) {
[items addObject:message];
}
NSURL *URL = [RCTConvert NSURL:options[@"url"]];
if (URL) {
- [items addObject:URL];
+ if (URL.fileURL || [URL.scheme.lowercaseString isEqualToString:@"data"]) {
+ NSError *error;
+ NSData *data = [NSData dataWithContentsOfURL:URL
+ options:(NSDataReadingOptions)0
+ error:&error];
+ if (!data) {
+ failureCallback(error);
+ return;
+ }
+ [items addObject:data];
+ } else {
+ [items addObject:URL];
+ }
}
if (items.count == 0) {
RCTLogError(@"No `url` or `message` to share");