6

I have the following rule set

<dict>
            <key>NSExtensionActivationRule</key>
            <string>
                SUBQUERY (
                extensionItems,
                $extensionItem,
                SUBQUERY (
                $extensionItem.attachments,
                $attachment,
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "pdf" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.pdf" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
                ).@count == $extensionItem.attachments.@count
                ).@count == 1
            </string>
            <key>NSExtensionJavaScriptPreprocessingFile</key>
            <string>JavascriptPreprocessor</string>
        </dict>

and when i go to safari to a pdf, in iOS 10 i see the my share extension on iOS 11 i do not see it. Is there an extra uti-conforms-to i need to add to it be able to work on iOS 11 that anybody knows of?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Andy Jacobs
  • 15,187
  • 13
  • 60
  • 91

1 Answers1

4

I had exactly the same problem, and I noticed that some UTI (for example, public.url) disable the pdf UTI. If you remove them, the extension is shown when a pdf is loaded from a webpage. In other words, it seems like including one disable the other. My solution was manually finding the UTI that works for BOTH pdfs and web pages. If the pdf comes from a webpage, this configuration should work for you for iOS 11.0 and previous versions (at least it works in the simulator with xcode9).

SUBQUERY (
            extensionItems,
            $extensionItem,
            SUBQUERY (
            $extensionItem.attachments,
            $attachment,
            (
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text";
            )
            ).@count == $extensionItem.attachments.@count
            ).@count == 1

UPDATE: I have added

|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text"

to allow the extension to be seen by Chrome and Firefox in html and pdf documents.

Ruben Rizzi
  • 342
  • 1
  • 3
  • 20