美文网首页
iOS App Extension中按需求在插件列表显示的方案

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

作者: Cofey_c | 来源:发表于2023-03-06 16:40 被阅读0次

这里以显示网页链接为例子, 非浏览器的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>

相关文章

网友评论

      本文标题:iOS App Extension中按需求在插件列表显示的方案

      本文链接:https://www.haomeiwen.com/subject/wbvmldtx.html