When including a share or action extension in your app, you can use the NSExtensionActivationRule
key in your extension's Info.plist
file to specify the data types your extension is available for. If you want it to support a maximum of 1 image:
<key>NSExtension</key>
<dict>
...
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
...
</dict>
Sometimes, your filtering criteria might need to be more granular. You can use a NSPredicate string as the value of NSExtensionActivationRule
instead. E.g. if we want to specific that we only want Live Photos
(instead of all kinds of images), and we want exactly 1 live photo:
<key>NSExtension</key>
<dict>
...
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.live-photo"
).@count == $extensionItem.attachments.@count and $extensionItem.attachments.@count == 1
).@count == 1</string>
</dict>
...
</dict>
Your feedback is valuable: Do you want more nuggets like this? Yes or No
.