I am implementing UIActivityViewController to share text and image through other apps. My problem starts when WhatsApp doesn't accept text and image together, so I want to remove text (if exists) when user chooses to share with WhatsApp.
How can I remove some activity items after the destination app was choosen in UIActivityViewController?
First of all, you need to create a class that conforms to
UIActivityItemSource, and use it instead of passing the text or image directly toUIActivityViewController.So instead of
We would pass the new item sources
The item source classes will look something like this:
Now that we have control over what we'll share, we can choose what exactly we share with each app by checking
activityTypebefore returning the data, and if we think we should not send anything at all, we can simply returnnil.In your case, if you want to share the text item with all apps except WhatsApp, you can simply do this: