Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Crash while trying to share information through slack using UIActivityViewController

I am using an UIActivityViewController to show share options. The information I am trying to share consists of two pieces (a plain string and an url). The share is working through all the extensions like iMessages, Mail, Notes, Twitter, Facebook etc, but the app is crashing when I try to share through Slack. The weird thing is that the crash only happens if I am not debugging and it never crashes while debugging.

Code:

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[title, self] applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];

# UIActivityItemSource methods
- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
    return url;
}

- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {
    return url;
}

- (NSString*)activityViewController:(UIActivityViewController *)activityViewController subjectForActivityType:(NSString *)activityType {
    return title;
}

- (NSString *)activityViewController:(UIActivityViewController *)activityViewController dataTypeIdentifierForActivityType:(NSString *)activityType {
    return @"com.test.url";
}

- (UIImage *)activityViewController:(UIActivityViewController *)activityViewController thumbnailImageForActivityType:(NSString *)activityType suggestedSize:(CGSize)size {
    return image;
}

I also noticed that this crash is happening on the Flipboard app and it's working fine on the Twitter app.

Did anyone run into this issue? If so can you please let me know what's the issue and how this can be fixed?

like image 927
kans Avatar asked Dec 17 '25 06:12

kans


1 Answers

I've recently run into what sounds like the same issue. Sharing with Slack won't crash when you only have one item in the activityItems/initWithActivityItems array, but if you have more than that, it will crash. I don't know if you are experiencing that particular problem, but a workaround is to combine the url and text into one string object, if that will fit your use case. Seems like a problem with Slack that they need to address.

like image 156
grouchcan Avatar answered Dec 19 '25 20:12

grouchcan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!