При попытке поделиться 5 разными изображениями из WhatsApp до нашего приложения, он будет показывать последнее изображение 5 раз, но кроме WhatsApp означает из галереи или из нашего приложения в наше приложение, затем 5 разных изображений, показывающих нормальные в iOS, мы попробуем эту логику < /p>
DispatchQueue.global(qos: .userInteractive).async { [weak self] in
guard let self = self else { return }
guard let inputItem = self.extensionContext?.inputItems.first as? NSExtensionItem else { return }
guard var attachments = inputItem.attachments else { return }
// Remove unwanted MapKit item types
attachments.removeAll {
$0.hasItemConformingToTypeIdentifier("com.apple.mapkit.map-item")
}
let maxCount = attachments.count
debugPrint("handleShareObject:: Shared contents:", attachments)
for attachment in attachments {
if attachment.hasItemConformingToTypeIdentifier(self.imageContentType) {
self.handleShareObject(attachment: attachment, type: .image, maxCount: maxCount)
} else if attachment.hasItemConformingToTypeIdentifier(self.textContentType) {
self.handleShareObject(attachment: attachment, type: .text, maxCount: maxCount)
} else if attachment.hasItemConformingToTypeIdentifier(self.videoContentType) {
self.handleShareObject(attachment: attachment, type: .video, maxCount: maxCount)
} else if attachment.hasItemConformingToTypeIdentifier(self.fileAudioType) {
self.handleShareObject(attachment: attachment, type: .audio, maxCount: maxCount)
} else if attachment.hasItemConformingToTypeIdentifier(self.fileURLType) {
self.handleShareObject(attachment: attachment, type: .file, maxCount: maxCount)
} else if attachment.hasItemConformingToTypeIdentifier(self.urlContentType) {
self.handleShareObject(attachment: attachment, type: .url, maxCount: maxCount)
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... icates-sam