1

I don't believe there is a way to do what I am about to ask, but I figure I would ask just in case.

I am currently subclassing UIActivityItemProvider in order to provide customized messages for various social media platforms:

- (id)item
{
    if ([self.activityType isEqualToString:UIActivityTypePostToFacebook]) {
        //Possibly present some view modally here to let the user decide on text to return?
        return @"Some facebook message";
    } else if ([self.activityType isEqualToString:UIActivityTypePostToTwitter]) {
       return @"Some Tweet";      
    } 
}

The problem is that I'd like to provide the user an intermediary option on customizing the message ("Some facebook message") they want to post on facebook. Ideally this would be a UIActionSheet where they could pick one of three options on how they want their data formatted.

The UIActionSheet is just an example, but you can imagine other types of custom views presented in the segue from when a user hits the facebook icon until they see the actual UI where they type in their text for the post.

Is there any way to do this sort of behavior?

AbuZubair
  • 1,236
  • 14
  • 20

1 Answers1

0

You want to simply implement a subclass of NSObject and implement the UIActivityItemSource protocol. Then, from activityViewController:itemForActivityType: return an NSURL object. This will act as a URL attachment for the Facebook post with you pass it to UIActivityViewController.

If Facebook App is installed, it will open the app's share dialog, otherwise iOS Native share dialog will open with the URL as attachment.

According to Facebook guidelines, you cannot pre-fill the text of the share. You can do that with Twitter though but for that you have to have another subclass for NSObject and implement UIActivityItemSource and return an NSString from the same Message. This will act as the text of the tweet.

Similarly, I believe returning a UIImage can set it as attachment in Facebook.

zakishaheen
  • 5,551
  • 1
  • 22
  • 29