Remove Apps from the Share Sheet
Q: How do I remove the apps that get shown on the share sheet?
A: To customize / remove apps the share sheet, we use a DocumentSharingConfiguration
object. It defines the set of options available when sharing documents and also includes an option for excludedActivityTypes
that will help us customize / remove any unwanted apps on the share sheet. Please note that it currently not 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, we would do something like this:
1 2 3 4 5 6 | let sharingConfiguration = DocumentSharingConfiguration.defaultConfiguration(forDestination: .activity).configurationUpdated { $0.excludedActivityTypes = [.assignToContact, .postToWeibo, .postToFacebook, .postToTwitter] } let sharingController = DocumentSharingViewController(documents: [document]) sharingController.sharingConfigurations = [sharingConfiguration] |
1 2 3 4 5 6 7 | 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 that we excluded will not be shown in the share sheet.
For a more detailed explanation on all the different customizations available for the share sheet, check out our Document Sharing guide. We also have an example in our Catalog (CustomSharingOptionsExample
) which demonstrates several different ways to customize the share sheet.