1

I am trying to share an animated GIF but default UIActivityViewController Twitter share doesn't support it yet which it will "scale down" it as a still JPG, I have to use SLRequest for it as taught in this article. The downside of that is no preview share sheet and users cannot type their own message anymore.

However, I saw SteppyPants that it seems using a custom action after users click "share" in Twitter share sheet, how can they do it?

In other word, how to replace the UIActivityViewController twitter share action to a custom action which includes SLRequest.

Things I tried:

  • UIActivityItemProvider and check UIActivityTypePostToTwitter, but that's run after user click twitter and before editing the text
  • In UIActivityViewController completionWithItemsHandler delete the just twitted post (with still gif) and post again with SLRequest, but not too sure if I can delete the old post and it's consuming network bandwidth for users anyway
  • SLComposeViewController, does not support animated GIF upload and not custom share action at all

P.S. I am iOS newb

UIActivityViewController share options Replace custom action to share sheet

Community
  • 1
  • 1
Richard Fu
  • 616
  • 10
  • 27

1 Answers1

1

UIActivityItemProvider and check UIActivityTypePostToTwitter, but that's run after user click twitter and before editing the text

That's pretty close!

I believe Steppy Pants is doing what you said; providing a UIActivityItemProvider to the UIActivityViewController, but with a twist.

When the UIActivityItemProvider's item method is called, it checks if the UIActivityType is UIActivityTypePostToTwitter and if so, the UIActivityViewController is dismissed and a custom SLComposeServiceViewController is presented.

If you look closely you can see: The presented view controller doesn't have a title and the remaining character count doesn't respond correctly to URLs. The SLComposeServiceViewController object then implements didSelectPost to present a spinner UI while it initiates an SLRequest.

Matt Comi
  • 610
  • 6
  • 9
  • Looks well-explained answer! It has been a while so I moved on something else, will definitely come back and test it out! – Richard Fu Oct 24 '16 at 06:52