Excluding activity types for UIActivityViewController: some are still present

I try to exclude some activities from UIActivity.

It works as expected when exclusion is done directly with the activity, as with:

UIActivity.ActivityType.message,
UIActivity.ActivityType.airDrop

but not when activity is declared with an init as with:

UIActivity.ActivityType(rawValue: "net.whatsapp.WhatsApp.ShareExtension"),
UIActivity.ActivityType(rawValue: "com.ifttt.ifttt.share"),

So, with the following code:

        let excludedActivityTypes = [
                    UIActivity.ActivityType.message,
                    UIActivity.ActivityType.airDrop,
                    UIActivity.ActivityType(rawValue: "net.whatsapp.WhatsApp.ShareExtension"),
                    UIActivity.ActivityType(rawValue: "com.ifttt.ifttt.share")
                ]
        let activityVC = UIActivityViewController(activityItems: [modifiedPdfURL], applicationActivities: nil) 
        activityVC.excludedActivityTypes = excludedActivityTypes

message and airDrop do not show, but WhatsApp and IFTTT still show.

I have tested with

        activityVC.completionWithItemsHandler = { (activity, success, modifiedItems, error) in
            print("activity: \(activity), success: \(success), items: \(modifiedItems), error: \(error)")
        }

that WhatsApp and IFTTT services are effectively the ones listed here.

When selecting WhatsApp, print above gives:

activity: Optional(__C.UIActivityType(_rawValue: net.whatsapp.WhatsApp.ShareExtension)), success: false, items: nil, error: nil
Accepted Answer

Apps can only exclude the built-in system activity types (the constants listed in the UIActivity.ActivityType struct), and are not allowed to exclude extension activities that come from other apps.

Except that's not 100% accurate. That is the behavior in iOS. However, you can exclude 3rd party extension activities when you build for macOS (built for iPad) or Catalyst.

I am excluding .postToWeibo but still I can see Weibo in the options. My code is

var activityViewController = UIActivityViewController(activityItems: [documentId+".pdf", pDfdata], applicationActivities: nil)   

activityViewController.excludedActivityTypes = [.postToTwitter, .postToFacebook, .postToFlickr, .postToTencentWeibo, .postToVimeo, .postToWeibo]

present(activityViewController, animated: true)

Can you please let me know what is the reason for this?

@DivuaACN read the correct answer ; Apps can only exclude the built-in system activity types (the constants listed in the UIActivity.ActivityType struct), and are not allowed to exclude extension activities that come from other apps.

Excluding activity types for UIActivityViewController: some are still present
 
 
Q