Monday, December 19, 2016

Hiding Your Action and Share Extensions In Your Own Apps

Aditya Krishnadevan:

In PDF Viewer, we use a UIActivityViewController to share PDFs. This means that our Action extension shows up in the list of actions as well! So a user would see an "Import to PDF Viewer" button inside PDF Viewer. There isn't an easily available API to prevent this from happening. However, the extension's Info.plist does have NSExtensionActivationRule inside NSExtensionAttributes.

[…]

The important bit is AND NOT (ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "your.unique.uti.here"). This ensures that if the UIActivityViewController is created with any items matching your.unique.uti.here, your extension will not be displayed in the list of options. […] Next we need to add an item with a UTI matching your.unique.uti.here to the items passed into the UIActivityViewController.

Comments RSS · Twitter

Leave a Comment