January 9, 2015
With the release of iOS 8 came many third-party Share extensions to help users move data from the current app into another. The destination app can be a social network like Tumblr, a productivity app like Dropbox, or a utility like the immensely useful Mail to Self. In some cases, the source app knows which options don't make sense and should be hidden based on the content being shared. Developers express this restriction in code by adding NSString
activity type values to UIActivityViewController
's excludedActivityTypes
property.
Recently I needed to add share functionality to an app that showed some legalese and forms needed to complete a sign up process. Similar to how Apple provides an "Email me a copy" option in the iTunes Terms of Service dialog, the designer wanted the user to be able to consume the content in another app of their choice. For example, a PDF form could be printed or a long set of legalese could be more easily read in Instapaper or emailed to a desktop mail client. A few activity types clearly don't make sense in this scenario: sharing to social media and Assign to Contact. I looked around the web to see if someone has compiled a list of third-party activity types and had no success, so here is what I collected for the big social networks:
UIActivityTypePostToFacebook
or com.apple.UIKit.activity.PostToFacebook
UIActivityTypePostToTwitter
or com.apple.UIKit.activity.PostToTwitter
net.naan.TwitterFonPro.ShareExtension-Pro
com.hootsuite.hootsuite.HootsuiteShareExt
com.linkedin.LinkedIn.ShareExtension
pinterest.ShareExtension
com.google.GooglePlus.ShareExtension
com.tumblr.tumblr.Share-With-Tumblr
UIActivityTypePostToFlickr
or com.apple.UIKit.activity.PostToFlickr
UIActivityTypePostToVimeo
or com.apple.UIKit.activity.PostToVimeo
UIActivityTypePostToWeibo
or com.apple.UIKit.activity.PostToWeibo
UIActivityTypePostToTencentWeibo
or com.apple.UIKit.activity.TencentWeibo
wefwef.YammerShare
com.hootsuite.hootsuite.HootsuiteShareExt
Now that we have a list of activity types, all thats left is to add them to excludedActivityTypes
and the problem is solved! Unfortunately, iOS doesn't work the way you would expect:
As of iOS 8.1 UIActivityViewController
ignores third-party values in excludedActivityTypes
. The system options like UIActivityTypePostToFacebook
and UIActivityTypePostToTwitter
are okay, but anything that doesn't start with com.apple.UIKit.activity
is ignored. I opened Radar #19430419 for this issue, and if you would also like this functionality please open a duplicate of it. Sample code demonstrating the bug is available on GitHub.