Skip to content

Instantly share code, notes, and snippets.

@irace
Last active April 19, 2018 01:26
Show Gist options
  • Save irace/535c9aa3314ee41fb902 to your computer and use it in GitHub Desktop.
Save irace/535c9aa3314ee41fb902 to your computer and use it in GitHub Desktop.
Activity items and share extensions

I'm not 100% sure this is all accurate but:

It seems as though share extension predicates are a lot more specific than we originally thought. For example, if Instapaper declares support for only NSExtensionActivationSupportsWebURLWithMaxCount = 1, this means that activity controllers configured with a URL but also some other item types too, e.g. a string, won't show Instapaper.

So basically if you have multiple items in your activity items array, your controller will only show extensions that support all types. I imagine this would be extremely limiting, and as such, think the best option is to:

  • Only include a single provider in your items array. The provider would have a placeholder of a single type that will be provided to any activity or extension that isn't specifically accounted for
  • In the provider, specifically hardcode alternative item types for activities that need an alternative to the placeholder type:
    • "Copy" activity could use photo data, if present
    • "Mail" activity would get a string to use as the message body

This sucks because we're limiting how useful sharing from our app is if we only export a single data type. But I'm not sure that there's a way to be any more accomodating.

@Donohue
Copy link

Donohue commented Sep 5, 2014

Also FWIW, I can get a website from Safari via kUTTypePropertyList without NSExtensionActivationSupportsWebPageWithMaxCount, and NSExtensionActivationSupportsWebURLWithMaxCount must be at least 1. See:

https://devforums.apple.com/message/1014247#1014247

@lessthanyouthink
Copy link

Interesting… I'm hoping that we end up with extensions that are a little more lenient about what types of activity items they accept. I'm currently finishing up a feature that shares an image, string description, and a URL, and was aiming for compatibility with apps like Instagram, Tumblr, and Pinterest (if they offer extensions). I was originally using three activity items, but after reading this I've changed it to just an image and a string (with the URL as part of the string).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment