iOS共享扩展程序无法在图像url上使用

我有一个使用这些规则的共享扩展:

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

它适用于正常的网站和图像完美,但我不能parsing这样的图像url:( http://www.zappos.com/images/z/3/3/5/4/0/3/3354034-p- 2x.jpg )。 我厌倦了添加其他规则,但仍然我的共享扩展名将不会出现,当我用Safari打开这个网站,并点击共享。

但是,如果我使规则TRUEPREDICATE,我的共享扩展可以parsing网站。

我做错了什么? 谢谢

根据wj2061的回答,下面的谓词将抓取主机应用程序提供的所有附件。

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

你没有做错什么,只是因为Apple定义的常用键(下图)不能包含所有的情况。

在这里输入图像说明

对于你的情况,你必须编写你自己的NSPredicatestring,正如苹果在这里所build议的那样: 声明共享或操作扩展支持的数据types

我改变了苹果的例子:

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

您可以将public.image更改为任何其他统一types标识符 。

下面列出了一些常见的UTI:
在这里输入图像说明

我通过解决这个问题

 <key>NSExtensionActivationRule</key> <string>SUBQUERY ( extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ( ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;com.adobe.pdf&quot; || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;public.image&quot; || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;public.url&quot; ) ).@count == $extensionItem.attachments.@count ).@count > 0</string> 

最后一行@count> 0为我做了诡计。