iosuiactivity

Customising UIActivity for UIActivityTypeMessage


I'm sharing an image and its description text using UIActivityType. I need to share the URL of the image if I choose SMS sharing option. How can I do that? Currently I'm sharing the image and data to Facebook and Twitter. How to send the URL in case that SMS option is selected?


Solution

  • You can share the image using SMS option in the same way that you are doing it with Facebook and Twitter.

    The activityType for SMS is UIActivityTypeMessage. It is the built-in activityType.

    So the only thing you need to do is provide image and image description as activityItems while creating your UIActivityController.

    The code snippet is given below:

    NSString *imageDescription = @"Image Description Goes Here";
    UIImage *image = [UIImage imageNamed:@"Image_Name"];
    NSArray *items = [NSArray arrayWithObjects: imageDescription,image,nil];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
    [self presentViewController:activityVC animated:YES completion:nil];