我的共享扩展程序有以下NSExtensionActivationRule,它允许我的应用程序与图像和pdf文件进行交互:
SUBQUERY (
extensionItems, $extensionItem,
SUBQUERY (
$extensionItem.attachments, $attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
).@count == 1
).@count > 0
但是,由于我使用不同的方法来访问我自己的文件,因此我的应用不需要显示我的应用文档类型为com.myApp.extension
的文件。
是否有提炼:
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url
因此不包括特定类型的文件。
感谢
Reza
答案 0 :(得分:3)
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
(ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" OR
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" OR
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" OR
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" OR
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png")
AND NOT (ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "your.unique.uti.here")
).@count == $extensionItem.attachments.@count
).@count == 1
</string>
</dict>
答案 1 :(得分:0)
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
(
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" OR
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" OR
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" OR
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png")
AND NOT (ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "YourIdentifier")
).@count >= 1
).@count == 1
</string>
<key>NSExtensionJavaScriptPreprocessingFile</key>
<string>DemoPreprocessor</string>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>3</integer>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
class ActionExtensionBlockerItem: NSObject, UIActivityItemSource {
func activityViewController(_ activityViewController: UIActivityViewController, dataTypeIdentifierForActivityType activityType: UIActivityType?) -> String {
return "com.tops.pushnotification";
}
func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivityType) -> Any? {
// Returning an NSObject here is safest, because otherwise it is possible for the activity item to actually be shared!
return NSObject()
}
func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivityType?) -> String {
return ""
}
func activityViewController(_ activityViewController: UIActivityViewController, thumbnailImageForActivityType activityType: UIActivityType?, suggestedSize size: CGSize) -> UIImage? {
return nil
}
func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any {
return ""
}
}
if let myWebsite = NSURL(string: url) {
let objectsToShare = [textToShare, ActionExtensionBlockerItem()] as [Any]
// let activityViewController = UIActivityViewController(activityItems: [/* Items to be shared, */ ActionExtensionBlockerItem()], applicationActivities: nil)
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
// let item = NSItemProvider()
activityVC.excludedActivityTypes = [UIActivityType.airDrop,UIActivityType.print, UIActivityType.postToWeibo, UIActivityType.copyToPasteboard, UIActivityType.addToReadingList, UIActivityType.postToVimeo, UIActivityType.init(rawValue: "com.tops.pushnotification")]