How to customize UIActivityViewController

We are currently developing an enterprise iOS application and are in the process of implementing Data Leakage Protection (DLP) features. As part of this effort, we need to control the available actions and target applications presented within the UIActivityViewController.

Specifically, we would like to programmatically filter or restrict certain activities and destination apps shown in the share sheet based on user-specific permissions. These permissions will be dynamically evaluated and updated at runtime.

This type of functionality is supported by the Microsoft Intune SDK. However, our objective is to implement this behavior natively within our application without relying on any third-party libraries.

Could you please advise on the recommended approach or available APIs to achieve this level of control over the UIActivityViewController?

Have a look at the excludedActivityTypes property of UIActivityViewController. That lets you specify which activities you do not want to appear.

The hard part is determining the activity type for the different activities. Some are listed in the documentation for UIActivity.ActivityType. Many others are not. One trick I've used is to make use of the completionWithItemsHandler. Then look at the activityType value provided to the handler when an activity is selected.

This screenshot is from Microsoft Teams app. Here they are filtering all other third party apps and only allowing few apps. This same behaviour I need to achieve.

Maybe they are not using UIActivityViewController. It's not that hard to recreate the same user interface (I've done it myself, mostly). Then you have full control over what appears.

The API highlighted by @RickMaddy is one of the only choices, in addition to the newer excludedActivitySectionTypes property.

It's worth though taking a step back and looking at your core premises:

We are currently developing an enterprise iOS application and are in the process of implementing Data Leakage Protection (DLP) features.

In broad terms, an app generally does not have the right level of visibility to understand the mix of user intention and corporate data policies. An app is not an island, and may be only one of several apps to get specific work tasks done. That's why the right thing here is that the device needs to be managed by the enterprise through MDM, so there's a higher level view of what the enterprise intends to allow and disallow through its chosen policies. There's a chain of trust to this — if an enterprise doesn't trust the device by managing it at the device level, then why should it trust a potentially unknown device with an unmanaged app with its sensitive enterprise data?

There is an app developer component to participating in managed devices. I don't think this is of use to you specifically with the UIActivityViewController question here, but perhaps this is useful for other aspects of your work — the ManagedApp framework. This lets an IT department push configuration data, as well as secrets, to an app, which can then configure itself based on that information. We did a session on it at WWDC25.

— Ed Ford,  DTS Engineer

How to customize UIActivityViewController
 
 
Q