30

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

Md. Ibrahim Hassan
  • 5,359
  • 1
  • 25
  • 45
Seamus
  • 1,107
  • 10
  • 22
  • having the same issue on iOS 8.1.1. Seems like it might be an apple-side bug. – ilyashev May 09 '15 at 18:52
  • It looks like you're seeing the Facebook share extension (which is part of Facebook iOS app). Do you have Facebook app installed (and which version)? – amudi May 13 '15 at 08:04
  • Yes, it is the Facebook share extension. I referenced this in my question actually. But the point is that if Facebook makes use of a share extension then it is not possible to disable Facebook sharing so : excludedActivityTypes = @[UIActivityTypePostToFacebook, etc. is not usable. – Seamus May 14 '15 at 09:51
  • I am running Facebook Version 30.0, updated on May 7th. (I allow auto update) – Seamus May 14 '15 at 09:53
  • Does adding com.facebook.Facebook.ShareExtension to exludedActivityTypes help? – Xcoder May 23 '15 at 21:23
  • 4
    I have a similar situation in my app. Looks like on iOS 8.3 it is fixed and on iOS <= 8.2 it occurs. Still investigating but pretty sure @ilyashev is right it's an Apple bug. – charmingToad Jun 03 '15 at 19:13

2 Answers2

5

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

Chirag Jain
  • 628
  • 11
  • 24
shashi Gupta
  • 141
  • 1
  • 11
0
//Hope this helps . This is how it is done in Swift 3.

  //  When Including the FB Option the code is as follow:

      func otherSharing() {

            let activityItem: [AnyObject] = [returnFinalImage() as AnyObject]


            let avc = UIActivityViewController(activityItems: activityItem as [AnyObject], applicationActivities: nil)
             avc.excludedActivityTypes = [UIActivityType.addToReadingList, UIActivityType.assignToContact, UIActivityType.print, UIActivityType.saveToCameraRoll, UIActivityType.copyToPasteboard, UIActivityType.airDrop, UIActivityType.postToTwitter]
            self.present(avc, animated: true, completion: nil)
        }

    //When Excluding the FB Option the code is as follow:

        func otherSharing() {

            let activityItem: [AnyObject] = [returnFinalImage() as AnyObject]


            let avc = UIActivityViewController(activityItems: activityItem as [AnyObject], applicationActivities: nil)
             avc.excludedActivityTypes = [UIActivityType.addToReadingList, UIActivityType.assignToContact, UIActivityType.print, UIActivityType.saveToCameraRoll, UIActivityType.copyToPasteboard, UIActivityType.airDrop, UIActivityType.postToFacebook, UIActivityType.postToTwitter]
            self.present(avc, animated: true, completion: nil)
        }

    //I have Added Screen shot : [![enter image description here][1]][1]


      [1]: https://i.stack.imgur.com/IGzqC.jpg
Swifty Codes
  • 992
  • 10
  • 23