I want my extension support text, url, video and 10 images.
I have configured plist as below:

This work fine but I want my extension does not support image and video at the same time.
I understand that I'll most probably have to build a "SUBQUERY(..)" statement. My predicate like this:
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,(
     NOT ( ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
           AND ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie")
     ) AND (
           ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
        || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text"
        || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
        || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
        || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text")
).@count < 10
).@count == 1
But it doesn't work for me. How do I use in this case. Thanks for any help!
You can use Parth Adroja's answer for sharing images or videos based on a particular count. In my particular case, the extension was supposed to share either 4 images or 1 video and they were mutually exclusive.
Here is what I did.
<key>NSExtensionActivationRule</key>
<string>
    SUBQUERY (
      extensionItems,
      $extensionItem,
      (
        SUBQUERY (
          $extensionItem.attachments,
          $attachment,
          ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" ||
          ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"
        ).@count <= 4
        AND
        SUBQUERY (
          $extensionItem.attachments,
          $attachment,
          ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
        ).@count == 0
      )
      OR
      (
        SUBQUERY (
          $extensionItem.attachments,
          $attachment,
          ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" ||
          ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"
        ).@count == 0
        AND
        SUBQUERY (
          $extensionItem.attachments,
          $attachment,
          ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
        ).@count == 1
      )
      OR
      (
        SUBQUERY (
         $extensionItem.attachments,
         $attachment,
           ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text" OR
           ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text" OR
           ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" OR
        ).@count == 1
      )
    ).@count >= 1
</string>
Here's one I just used for myself. This only allows 1 item, either any video type or any image type. I modified an example from apple's documentation.
SUBQUERY (
    extensionItems,
    $extensionItem,
    SUBQUERY (
        $extensionItem.attachments,
        $attachment,
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
    ).@count == 1
).@count == 1
For easy of use copying directly into the plist:
SUBQUERY (extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ).@count == 1).@count == 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With