Remove Apps from the Share Sheet

It’s possible to remove the apps that get shown on the share sheet. To customize or remove them, use a DocumentSharingConfiguration object. It defines the set of options available when sharing documents, and it also includes an option for excludedActivityTypes, which will help you customize or remove any unwanted apps on the share sheet. Note that it isn’t possible to exclude all third-party applications from the share sheet; this is a restriction of Apple’s UIActivityViewController.

To remove unwanted apps from the share sheet, do something like this:

let sharingConfiguration = DocumentSharingConfiguration.defaultConfiguration(forDestination: .activity).configurationUpdated {
    $0.excludedActivityTypes = [.assignToContact, .postToWeibo, .postToFacebook, .postToTwitter]
}

let sharingController = DocumentSharingViewController(documents: [document])
sharingController.sharingConfigurations = [sharingConfiguration]
PSPDFDocumentSharingConfiguration *activitySharingConfiguration = [PSPDFDocumentSharingConfiguration defaultConfigurationForDestination:PSPDFDocumentSharingDestinationActivity];
PSPDFDocumentSharingConfiguration *sharingConfiguration = [activitySharingConfiguration configurationUpdatedWithBuilder:^(PSPDFDocumentSharingConfigurationBuilder *config) {
    config.excludedActivityTypes = @[UIActivityTypeAssignToContact, UIActivityTypePostToWeibo, UIActivityTypePostToFacebook, UIActivityTypePostToTwitter];
}];

PSPDFDocumentSharingViewController *sharingController = [[PSPDFDocumentSharingViewController alloc] initWithDocuments:@[document]];
sharingController.sharingConfigurations = @[sharingConfiguration];

Now when the share sheet is shown, the activity types you exclude won’t be shown.

For a more detailed explanation of all the different customizations available for the share sheet, refer to our document sharing guide. We also have an example in our Catalog (CustomSharingOptionsExample), which demonstrates several different ways to customize the share sheet.