iOS 中的 SUBQUERY 共享扩展名排除文件类型
SUBQUERY in iOS Share Extension Exclude file Types
我的共享扩展有以下 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
以便排除特定类型的文件。
谢谢
礼萨
<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>
<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")]
我的共享扩展有以下 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
以便排除特定类型的文件。
谢谢
礼萨
<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>
<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")]