Search code examples
iostypeid

SUBQUERY in iOS Share Extension Exclude file Types


I have the following NSExtensionActivationRule for my shared extension which allows my app to interact with images and pdf files:

SUBQUERY (
    extensionItems, $extensionItem,
    SUBQUERY (
        $extensionItem.attachments, $attachment,
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" ||
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
    ).@count == 1
).@count > 0

However, as I use a different method to access my own files, I need for my app not to be displayed for files with my apps document type com.myApp.extension.
Is there anyway of refining:

ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url

so that it excludes files of particular type.

Thanks
Reza


Solution

  • <key>NSExtensionAttributes</key>
    <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.url" OR
                    ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" OR
                    ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png")
                    AND NOT (ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "your.unique.uti.here")
                ).@count == $extensionItem.attachments.@count
        ).@count == 1
        </string>
    </dict>