ajith-ab / react-native-receive-sharing-intent

A React Native plugin that enables React Native apps to receive sharing photos, videos, text, urls or any other file types from another app
MIT License
305 stars 109 forks source link

[SOLVED] How to filter video or image exclusively #49

Open nschild opened 3 years ago

nschild commented 3 years ago

Thought I would share this: https://stackoverflow.com/a/62553607

The rules here are: max 4 images or max 1 video or max 1 URL

edit as you need

<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 &lt;= 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 &gt;= 1
</string>