Can't AirDrop more than one object type at the same time

I'm trying to share both a csv and a pdf file from my iPhone app (tried from both iPhone SE and iPhone X) to my Mac Pro 2018 using AirDrop from the UIActivityViewCointroller, but it fails. I read a post from 2016 in another forum stating the same issue with simultaneously sending multiple different object types with AirDrop.


Anyone who knows if there's a workaround to fix this problem today or if it's still a restriciton in AirDrop?


//  Write to the temporary file.
csvText.write(to: path, atomically: true, encoding: String.Encoding.utf8)

DispatchQueue.main.async {
let f = self.myEVAChartView.getChartImage(transparent: false)!

let pdfCreator = PDFCreator(title: (self.title ?? "No title"), body: (self.note ?? "No notes"), image: f, contact: mail)
let pdfData = pdfCreator.createReport()

// Init Activity view controller.
let activity = UIActivityViewController(
    activityItems: [path, pdfData],
  applicationActivities: nil
)

//Show the Activity view controller.
self.progressHUD.hide()
activity.popoverPresentationController?.barButtonItem = sender
activity.excludedActivityTypes = [.addToReadingList, .assignToContact, .copyToPasteboard, .markupAsPDF, .message, .openInIBooks, .postToFlickr, .postToTencentWeibo, .postToTwitter, .postToFacebook, .postToVimeo, .postToWeibo, .print, .saveToCameraRoll]
self.present(activity, animated: true, completion: nil)

Replies

Just an idea, for what it's worth.


Could you try:


let activity = UIActivityViewController( activityItems: [path as Any, pdfData as Any],  applicationActivities: nil )

Thanks for the idea! I tried, but unfortunately it still fails. 😕

Too bad.


If I understand this correctly,

https://stackoverflow.com/questions/26551408/share-data-with-different-types-in-uiactivityviewcontroller


you should create

UIActivityItemSource for each object to pass.


It's ObjC, but should not be too hard to convert to Swift.

Thanks! I will try that! 😀

Did it work ?