【问题标题】:Share Extension Google Chrome - Not working共享扩展 Google Chrome - 不工作
【发布时间】:2017-03-20 18:34:32
【问题描述】:

我在让我的共享扩展程序显示在 Google Chrome 中时遇到问题。它在 Safari 中显示并运行良好,但在 Chrome 中不显示。我正在使用以下激活规则,它也适用于其他应用程序(图像、pdf、共享文本),但它在 chrome 中丢失。

来自我的 info.plist:

<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <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" ||
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text" ||
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" ||
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"  ||
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf"
            ).@count == 1
        ).@count == 1
        </string>
        <key>NSExtensionJavaScriptPreprocessingFile</key>
        <string>GetURL</string>
    </dict>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.share-services</string>
    <key>NSExtensionMainStoryboard</key>
    <string>MainInterface</string>
</dict>

有什么想法吗?

【问题讨论】:

    标签: ios google-chrome ios-extensions


    【解决方案1】:

    对于您在 Chrome 中看不到您自己的 App shareExtension 的问题,您无法在 Chrome 中正常看到您的 shareExtension 的原因是您的 NSExtensionActivationRule 与 Chrome 不匹配。这个问题的答案与密钥(NSExtensionActivationSupportsAttachmentsWithMaxCount)有关。 :P

    我向你展示了我的 plist,它在 Chrome 和 Safari 中运行良好。

        <key>NSExtensionActivationRule</key>
        <dict>
            <key>NSExtensionActivationSupportsAttachmentsWithMaxCount</key>
            <integer>2</integer>
            <key>NSExtensionActivationSupportsImageWithMaxCount</key>
            <integer>0</integer>
            <key>NSExtensionActivationSupportsMovieWithMaxCount</key>
            <integer>0</integer>
            <key>NSExtensionActivationSupportsText</key>
            <true/>
            <key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
            <integer>1</integer>
            <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
            <integer>1</integer>
        </dict>
    

    您需要做的就是将 Key - NSExtensionActivationSupportsAttachmentsWithMaxCount 的值更改为 > 1,我认为原因是 Chrome 将其数据传递给 extensionContext!.inputItems[1] 而不是 extensionContext!.inputItems[0],您可以尝试自行设置此 Key 的不同值。

    希望这可以帮助你:)

    【讨论】:

    • 您好,我还想在 1Password 和 Dashlane 应用程序等原生应用程序中添加用于自动填充密码的 crome 共享扩展程序我如何开始使用此功能,请您给我一些关于此的基本想法。需要帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-26
    • 2013-02-18
    • 2012-11-25
    • 1970-01-01
    • 1970-01-01
    • 2021-10-17
    相关资源
    最近更新 更多