I wish to create a UIActivityViewController which will exclude some of the native share features including Facebook and Twitter Share. But the Facebook share is still available as a ShareExtention.
I create the following :
activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
and excluded Facebook by setting the excluded Activity types.
activityViewController.excludedActivityTypes = @[
UIActivityTypeAddToReadingList,
UIActivityTypeAssignToContact,
UIActivityTypePrint,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAirDrop,
UIActivityTypePostToFacebook,
UIActivityTypePostToTwitter
];
When running on my iPhone the Facebook icon appears despite being excluded.
Investigating how this is happening I see that the completion handler for the activity controller is returning the activityType = com.facebook.Facebook.ShareExtension, not UIActivityTypePostToFacebook. Also when selecting the more button in the activity controller there is a toggle for Facebook as for other apps which make use of the Share convention.
Why is Facebook using the shareExtention when Twitter is not, and why can I not exclude it using the excluded activities?
Note: I have tested this on several devices but the issue only exists on one device which is running 8.1.3.
Thanks
Try this way
// sharing items in an array lets say sharingItems
NSArray *sharingItems = @[@"hello", @"how", @"are", @"You."];
//making UIActivityViewController object lets say avc
UIActivityViewController *avc = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
//exclude UIActivityTypePostToFacebook
avc.excludedActivityTypes = @[UIActivityTypePostToFacebook];
//presenting UIActivityViewController in our case avc
[self presentViewController:avc animated:YES completion:nil];
see the below picture, Facebook is not included

When commenting avc.excludedActivityTypes = @[UIActivityTypePostToFacebook]; Facebook again becomes visible in share option
![click to enlarge When commenting avc.excludedActivityTypes = @[UIActivityTypePostToFacebook]; Facebook again becomes visible in share option](https://i.stack.imgur.com/HqW4im.png)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With