iOS App Extension中按需求在插件列表显示的方案

这里以显示网页链接为例子, 非浏览器的App分享出来的链接可能不是单纯的URL
所以设置
NSExtensionActivationSupportsWebURLWithMaxCount = 1 或者NSExtensionActivationSupportsWebPageWithMaxCount = 1
是无法解析到的

如果只是单纯的需要在photos里显示, 仅仅需要在NSExtensionActivationRule中设置以下内容就可以了

NSExtensionActivationSupportsImageWithMaxCount > 0 

参考设置:
这里的规则是显示URL, 包括非浏览器的shared, 同时在相册里不显示

<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.file-url"
                        || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.item"
                )
                AND
                (
                     NOT ( ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg-2000"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.quicktime-image"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.camera-raw-image"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.live-photo"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.video"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.avi"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.protected-mpeg-4-video"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.mpeg-4"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.mpeg-2-video"
                     || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.mpeg")
                     
                )

    ).@count == $extensionItem.attachments.@count
).@count == 1</string>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容