iOS 11 PDF共享扩展

时间:2017-10-19 09:30:51

标签: ios pdf ios11 share-extension

我有以下规则集

<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>

当我去野生动物园观看pdf时,在iOS 10中我看到我在iOS 11上的分享扩展我看不到它。是否有额外的uti-conforms-to我需要添加到它能够在任何人都知道的iOS 11上工作?

1 个答案:

答案 0 :(得分:3)

我有完全相同的问题,我注意到一些UTI(例如,public.url)禁用了pdf UTI。如果删除它们,则在从网页加载pdf时会显示扩展名。换句话说,似乎包括一个禁用另一个。我的解决方案是手动查找适用于两个pdf和网页的UTI。如果pdf来自网页,则此配置适用于iOS 11.0及以前的版本(至少它适用于带有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

更新:我已添加

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

允许Chrome和Firefox在html和pdf文档中看到扩展程序。