iostwittergifuiactivityviewcontrollerslrequest

Replace UIActivityViewController twitter post action with a SLRequest


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:

P.S. I am iOS newb

UIActivityViewController share options Replace custom action to share sheet


Solution

  • 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.