2017-03-20 50 views
0

我在讓我的共享擴展程序顯示在谷歌瀏覽器中遇到問題。它在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" 
      )[email protected] == 1 
     )[email protected] == 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> 

任何想法?

回答

2

對於你的問題有關無法看見自己的應用程序shareExtension在Chrome中,你看不到你在Chrome shareExtension通常是你的不匹配的Chrome NSExtensionActivationRule的原因。此問題的答案與密鑰(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> 

所有你需要做的是關鍵的值更改 - NSExtensionActivationSupportsAttachmentsWithMaxCount多項> 1,我想原因是Chrome瀏覽器將其資料到extensionContext .inputItems [1],而不是extensionContext .inputItems! [0],你可以嘗試自己設置這個Key的不同值。

希望這可以幫助你:)

+0

幫助了我很多,謝謝你! – oronbz

+0

哇!非常感謝。 – Deleplace

+0

嗨,我也想在這樣的1Password和Dashlane應用原生應用程序添加共享擴展爲克羅姆密碼自動填充不 我如何開始工作,這個你可以請給我關於一些基本概念。 需要幫助。 – Anita