问题
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
回答1:
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>
回答2:
You did nothing wrong,it's just because the common keys (of the following chart) defined by Apple cannot include all cases.
For your case , you have to write your own NSPredicate String as Apple suggested here:Declaring Supported Data Types for a Share or Action Extension
I changed apple's example like this:
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image";
).@count == $extensionItem.attachments.@count
).@count == 1
</string>
</dict>
You can change public.image
to any other Uniform Type Identifiers.
Some of the common UTIs are listed below:
回答3:
I resolved this issue by
<key>NSExtensionActivationRule</key>
<string>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 == $extensionItem.attachments.@count
).@count > 0</string>
The last line @count > 0 did the trick for me.
来源:https://stackoverflow.com/questions/38226283/ios-share-extension-not-working-on-image-urls