Search code examples
iosios-extensions

iOS Share extension not working on image urls


I have a share extension that uses those rules:

<dict>
    <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
    <integer>1</integer>
    <key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
    <integer>1</integer>
    <key>NSExtensionActivationSupportsImageWithMaxCount</key>
    <integer>10</integer>
    <key>NSExtensionActivationSupportsText</key>
    <integer>1</integer>
</dict>

It works perfectly for normal websites and images but I can't parse image urls like this : ( http://www.zappos.com/images/z/3/3/5/4/0/3/3354034-p-2x.jpg ). I tired to add other rules but still my share extension won't appear when I open this website with Safari and click share.

But if I make rule TRUEPREDICATE, my share extension can parse the site.

What I am doing wrong? Thanks


Solution

  • Building off of wj2061's answer, the following predicate will grab any and all attachments supplied by the host app.

    <key>NSExtensionActivationRule</key>
    <string>SUBQUERY (
        extensionItems,
        $extensionItem,
        SUBQUERY (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.item" ||
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.content"
        ).@count == $extensionItem.attachments.@count
        ).@count > 0
    </string>