5

I need to share pdf files from other application through my Share extension. In my share extension, I am using this NSExtensionActivationRule

<key>NSExtensionActivationRule</key>
<string>SUBQUERY (
        extensionItems,
        $extensionItem,
        SUBQUERY (
           $extensionItem.attachments,
           $attachment,(
           ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf";
           || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url";
        ).@count == $extensionItem.attachments.@count
   ).@count == 1
</string>

For URL contents, I was able to see my app icon in all the activation controllers of other applications. But I need to activate the extension only for PDF urls.

Can I create an NSExtensionActivationRule, which can select all the pdf files for sharing through Share extension including URL and contents.?

Nobin Thomas
  • 181
  • 11

1 Answers1

1

I was able to to get my share extension to recognize PDFs, images, GIFs, and plain text by using the following subquery in my Info.plist:

<key>NSExtensionActivationRule</key>
<string>SUBQUERY (
      extensionItems, 
      $extensionItem,
      SUBQUERY (
          $extensionItem.attachments, 
          $attachment,
           ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" ||
           ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text" ||
           ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
           ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.compuserve.gif"
        ).@count == $extensionItem.attachments.@count
        ).@count == 1
</string>
laus102
  • 91
  • 1
  • 4