Is it possible to share NSURL
and NString
at the same time using the UIActivityViewController
?
I know it's possible using the MFMessageComposeViewController
but wanted to use the native UI sheet so the user can select a different app if they wanted.
In this example, the filePath variable is a path to a video file saved on the device.
NSMutableArray *items = [NSMutableArray new];
[items addObject:[NSURL fileURLWithPath:filePath]];
UIViewController *rootViewController = UnityGetGLViewController();
UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
[rootViewController presentViewController:activity animated:YES completion:nil];
Updating the items with an additional string value will result in only the video being shared.
NSMutableArray *items = [NSMutableArray new];
[items addObject:[NSURL fileURLWithPath:filePath]];
[items addObject:[NSString stringWithUTF8String:"Check out this video!"]];
UIViewController *rootViewController = UnityGetGLViewController();
UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
[rootViewController presentViewController:activity animated:YES completion:nil];
The "Check out this video!" text is never included in the iMessage app.
Is this something that is possible? If not It would be nice to see some official Apple documentation about this. Also, this would be quite surprising considering iMessage is a built-in app, you would imagine it would have this capability.