Here is my code:
NSSharingService *service = [NSSharingService sharingServiceNamed: NSSharingServiceNameComposeMessage];
tempURL = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"test.zip"]]
[service performWithItems:@[@"test", tempURL]];
The message window is properly shown, as well as the 'test' text, but the file is not included in the message.
What works:
NSSharingServiceNameComposeEmail
insteadSimilar issues:
NSSharingServiceNameSendViaAirDrop
Any ideas what else I could try? Thanks!
Apparently you can share a zip file but It doesn't show up on the share sheet.
I tested It and when I sent the message to myself I got the zip file attached.
- (IBAction)shareZipFile:(id)sender {
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
openPanel.allowedFileTypes = @[@"zip"];
openPanel.prompt = @"Share";
[openPanel runModal];
NSSharingService *service = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeMessage];
NSArray *items = @[openPanel.URL.lastPathComponent.stringByDeletingPathExtension, openPanel.URL];
if (![service canPerformWithItems:items]) {
NSLog(@"Can't share that kind of stuff, sorry!");
return;
}
[service performWithItems:items];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With