Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't exclude UIActivityTypePostToFacebook from [UIActivityViewController excludedActivityTypes]

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

like image 813
Seamus Avatar asked May 06 '15 13:05

Seamus


1 Answers

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

In image Facebook not included

When commenting avc.excludedActivityTypes = @[UIActivityTypePostToFacebook]; Facebook again becomes visible in share option

When commenting  avc.excludedActivityTypes = @[UIActivityTypePostToFacebook]; Facebook again becomes visible in share option

like image 178
shashi Gupta Avatar answered Nov 19 '22 09:11

shashi Gupta