Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize ActionSheetManager items URL #15475

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions Libraries/ActionSheetIOS/RCTActionSheetManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,17 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
if (message) {
[items addObject:message];
}
NSURL *URL = [RCTConvert NSURL:options[@"url"]];
if (URL) {
if ([URL.scheme.lowercaseString isEqualToString:@"data"]) {
NSArray<NSURL *> *URLS = [RCTConvert NSURLArray:options[@"url"]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking API change that introduces crashes into all existing apps using it. Highly suggest introducing a "urls" argument instead.


if (URLS.count == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that passing in "message" will always crash.

RCTLogError(@"No `url` or `message` to share");
return;
}

for (NSURL *url in URLS) {
if ([url.scheme.lowercaseString isEqualToString:@"data"]) {
NSError *error;
NSData *data = [NSData dataWithContentsOfURL:URL
NSData *data = [NSData dataWithContentsOfURL:url
options:(NSDataReadingOptions)0
error:&error];
if (!data) {
Expand All @@ -146,13 +152,9 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
}
[items addObject:data];
} 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];

Expand Down