mirror of
https://github.com/status-im/react-native.git
synced 2025-02-10 16:36:25 +00:00
Generalize ActionSheetManager items URL
Summary: Not ready but want to start conversation. (i.e. not sure if to change key name to `urls` from `url`) I want to be able to share more than 1 image at a time, the current code only lets one use one url, but the API allows for much more. Some places already make this an issue: https://github.com/EstebanFuentealba/react-native-share/issues/85 And I also need to be able to email/send on iMessage, etc with multiple URL resources. Closes https://github.com/facebook/react-native/pull/15475 Differential Revision: D6437807 Pulled By: hramos fbshipit-source-id: 336c696c5633c0080904ca9306a38120e27f9173
This commit is contained in:
parent
c6fe101cdc
commit
2e424fb113
@ -133,11 +133,17 @@ RCT_EXPORT_METHOD(showShareActionSheetWithOptions:(NSDictionary *)options
|
|||||||
if (message) {
|
if (message) {
|
||||||
[items addObject:message];
|
[items addObject:message];
|
||||||
}
|
}
|
||||||
NSURL *URL = [RCTConvert NSURL:options[@"url"]];
|
NSArray<NSURL *> *URLS = [RCTConvert NSURLArray:options[@"url"]];
|
||||||
if (URL) {
|
|
||||||
if ([URL.scheme.lowercaseString isEqualToString:@"data"]) {
|
if (URLS.count == 0) {
|
||||||
|
RCTLogError(@"No `url` or `message` to share");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NSURL *url in URLS) {
|
||||||
|
if ([url.scheme.lowercaseString isEqualToString:@"data"]) {
|
||||||
NSError *error;
|
NSError *error;
|
||||||
NSData *data = [NSData dataWithContentsOfURL:URL
|
NSData *data = [NSData dataWithContentsOfURL:url
|
||||||
options:(NSDataReadingOptions)0
|
options:(NSDataReadingOptions)0
|
||||||
error:&error];
|
error:&error];
|
||||||
if (!data) {
|
if (!data) {
|
||||||
@ -146,13 +152,9 @@ RCT_EXPORT_METHOD(showShareActionSheetWithOptions:(NSDictionary *)options
|
|||||||
}
|
}
|
||||||
[items addObject:data];
|
[items addObject:data];
|
||||||
} else {
|
} else {
|
||||||
[items addObject:URL];
|
[items addObject:url];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (items.count == 0) {
|
|
||||||
RCTLogError(@"No `url` or `message` to share");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UIActivityViewController *shareController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
|
UIActivityViewController *shareController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user