Andrey Chernukha
Andrey Chernukha

Reputation: 21808

App icon not shown in Safari in the share menu opened by a long press on a link

My app has an extension. This extension is available in Safari. When I use Safari share button

then it opens a share panel and my app icon is there. However if I hold down a link in Safari for a couple of seconds and the following alert pops up and I tap Share... button then it opens a similar share panel, I see that there are Facebook and Twitter icons but my app icon is missing. Does anybody know how to make it appear there in that share panel?

This is what opens when I tap "Share..." button:

enter image description here

Upvotes: 3

Views: 1450

Answers (1)

Andrey Chernukha
Andrey Chernukha

Reputation: 21808

I've found a solution. There's key named NSExtensionActivationRule in the plist of my extension. It belongs to NSExtensionAttributes dictionary which in its turn belongs to NSExtension dictionary. So the value for NSExtensionActivationRule looks as follows for me:

<string>SUBQUERY (
            extensionItems,
            $extensionItem,
            SUBQUERY (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" ||
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text"
            ).@count &gt;= 1
            ).@count &gt;= 1</string>

As far as I remember this is $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text" line which does all the magic.

The complete NSExtension dictionary looks as follows:

<key>NSExtension</key>
<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>NSExtensionActivationDictionaryVersion</key>
        <integer>2</integer>
        <key>NSExtensionActivationRule</key>
        <string>SUBQUERY (
            extensionItems,
            $extensionItem,
            SUBQUERY (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" ||
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text"
            ).@count &gt;= 1
            ).@count &gt;= 1</string>
        <key>NSExtensionActivationUsesStrictMatching</key>
        <integer>2</integer>
    </dict>
    <key>NSExtensionMainStoryboard</key>
    <string>MainInterface</string>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.share-services</string>
</dict>

Upvotes: 2

Related Questions