2016-12-02 81 views
2

我的應用程序有一個擴展名。此擴展程序在Safari中可用。當我使用Safari的份額按鈕在鏈接上長按打開的共享菜單中的Safari中未顯示的應用程序圖標

然後它會打開一個共享面板和我的應用程序圖標是存在的。但是,如果我在Safari中按住幾秒鐘的鏈接並彈出下面的警告,然後點擊Share...按鈕,它會打開一個類似的共享面板,我看到有Facebook和Twitter圖標,但是我的應用程序圖標已丟失。有人知道如何讓它出現在共享面板中嗎?

這是當我點擊打開什麼「分享」按鈕:

enter image description here

+0

你在添加擴展的應用程序圖標? – Venkat

+0

我不確定你的意思,但是如果你問我是否在Safari中啓用了應用程序擴展,那麼是的。正如我所說當我使用分享按鈕時,一切正常 –

+0

我的意思是,你會在你的Xcode項目中添加應用程序圖標嗎?您需要在Xcode項目中設置共享擴展的應用程序圖標。 – Venkat

回答

1

我已經找到了解決辦法。在我的擴展程序的plist中有一個名爲NSExtensionActivationRule的密鑰。它屬於NSExtensionAttributes字典,該字典本身屬於NSExtension字典。因此,對於NSExtensionActivationRule值找我如下:

<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" 
      )[email protected] &gt;= 1 
      )[email protected] &gt;= 1</string> 

至於我記得這是$attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text"線,做所有的魔法。

完整NSExtension字典如下所示:

<key>NSExtension</key> 
<dict> 
    <key>NSExtensionAttributes</key> 
    <dict> 
     <key>NSExtensionActivationDictionaryVersion</key> 
     <integer>2</integer> 
     <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" 
      )[email protected] &gt;= 1 
      )[email protected] &gt;= 1</string> 
     <key>NSExtensionActivationUsesStrictMatching</key> 
     <integer>2</integer> 
    </dict> 
    <key>NSExtensionMainStoryboard</key> 
    <string>MainInterface</string> 
    <key>NSExtensionPointIdentifier</key> 
    <string>com.apple.share-services</string> 
</dict> 
+0

謝謝。你能以XML格式發佈info.plist的NSExtension部分嗎?我的是這樣:'\t NSExtension \t \t \t NSExtensionAttributes \t \t \t \t \t NSExtensionActivationRule \t \t \t \t \t \t \t NS ExtensionActivationSupportsWebURLWithMaxCount \t \t \t \t \t \t \t \t \t \t \t NSExtensionMainStoryboard \t \t MainInterface \t \t NSExtensionPoin tIdentifier \t \t com.apple.share服務 \t ' – zisoft

+0

@zisoft完成。看看 –

+0

很有意思,謝謝!我會嘗試的。我假設'public.url'將在URL鏈接上長按。 – zisoft

相關問題