我应该使用什么 plist 设置来在 iOS8 中共享文档

What plist settings should I use to share documents in iOS8

我正在尝试在 iOS 中使用 SLComposeServiceViewController 共享文档,我正在测试它的文档是 pdf(尽管我需要共享任何文件的能力)。 我将我的 PDF 发送到 iPhone 上的 Mail,按住附件,但我的图标从未显示。 我有图像,URL 和文本共享工作正常,我似乎无法让任何类型的文档工作。

我假设 NSExtensionActivationSupportsAttachmentsWithMaxCount and/or NSExtensionActivationSupportsFileWithMaxCount 需要设置,但我不知道它们之间有什么区别。

这是我目前的 plist...

有人可以帮忙吗?

<key>NSExtension</key>
 <dict>
  <key>NSExtensionAttributes</key>
  <dict>
   <key>NSExtensionActivationRule</key>
   <dict>
    <key>NSExtensionActivationSupportsImageWithMaxCount</key>
    <integer>10</integer>
    <key>NSExtensionActivationSupportsAttachmentsWithMinCount</key>
    <integer>0</integer>
    <key>NSExtensionActivationSupportsAttachmentsWithMaxCount</key>
    <integer>20</integer>
    <key>NSExtensionActivationSupportsMovieWithMaxCount</key>
    <integer>0</integer>
    <key>NSExtensionActivationSupportsText</key>
    <true/>
    <key>NSExtensionActivationSupportsVideoWithMaxCount</key>
    <integer>0</integer>
    <key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
    <integer>0</integer>
    <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
    <integer>1</integer>
    <key>NSExtensionActivationSupportsFileWithMaxCount</key>
    <integer>1</integer>
   </dict>
  </dict>
  <key>NSExtensionMainStoryboard</key>
  <string>MainInterface</string>
  <key>NSExtensionPointIdentifier</key>
  <string>com.apple.share-services</string>
 </dict>

这些是谓词,所有这些都必须满足才能显示您的扩展。你可能只需要像这样的 NSExtensionActivationSupportsAttachmentsWithMinCount

<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>NSExtensionActivationRule</key>
        <dict>
            <key>NSExtensionActivationSupportsAttachmentsWithMinCount</key>
            <integer>1</integer>
        </dict>
        <key>NSExtensionPointName</key>
        <string>com.apple.share-services</string>
        <key>NSExtensionPointVersion</key>
        <string>1.0</string>
    </dict>

仅使用 TRUEPREDICATE 进行测试以确保谓词确实是问题的原因。

还有一件事:默认情况下不启用共享扩展,因此请确保选中共享目标列表末尾的更多 [...] 按钮。

您可以在扩展程序中使用此代码从 Mail(或类似)和 Dropbox(Box、iCloud 或类似)获取文件 info.plist

<key>NSExtension</key>
<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>NSExtensionActivationRule</key>
        <dict>
            <key>NSExtensionActivationSupportsFileWithMaxCount</key>
            <integer>1</integer>
            <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
            <integer>1</integer>
        </dict>
    </dict>
    <key>NSExtensionMainStoryboard</key>
    <string>MainInterface</string>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.share-services</string>
</dict>