【发布时间】:2020-06-01 09:38:36
【问题描述】:
从来没有分享过扩展。
从带有共享扩展的邮件应用程序共享附件无法正常工作。但从 Gmail 应用程序共享附件(pdf、doc、图像等)工作正常。
NSExtensionActivationRule
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsAttachmentsWithMaxCount</key>
<integer>1</integer>
</dict>
代码:-
for attachment in contents{
if attachment.hasItemConformingToTypeIdentifier(kUTTypeImage as String) {
attachment.loadItem(forTypeIdentifier: kUTTypeImage as String, options: nil) { data, error in
//Do action for image
}
} else {
if let item = (filePicker!.types as [String]).first(where: { (item) -> Bool in attachment.hasItemConformingToTypeIdentifier(item)}){
attachment.loadItem(forTypeIdentifier: item, options: nil) { data, error in
//Do action for file
}
}
}
}
【问题讨论】:
标签: ios swift ios13 ios-extensions ios-sharesheet