Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 11 PDF share Extension

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?

like image 638
Andy Jacobs Avatar asked Oct 19 '17 09:10

Andy Jacobs


1 Answers

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.

like image 93
Ruben Rizzi Avatar answered Oct 22 '22 21:10

Ruben Rizzi