I've been struggling with this for ages now as I can't find any detailed examples.
In my app I have an array of custom data that I want to send to another user with the same app, via AirDrop.
The first step is sending the data:
@IBAction func share_Button_Click(sender: UIBarButtonItem)
{
let dataToShare: NSData = getMyCustomNSData()
let controller = UIActivityViewController(activityItems: [dataToShare], applicationActivities: nil)
controller.excludedActivityTypes = [UIActivityTypePostToFacebook, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo, UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypePostToFlickr, UIActivityTypePostToTencentWeibo, UIActivityTypeMail, UIActivityTypeAddToReadingList, UIActivityTypeOpenInIBooks, UIActivityTypeMessage]
self.presentViewController(controller, animated: true, completion: nil)
}
This converts my data to an NSData object, the user gets the AirDrop share option, and of the data goes to another phone. So far so good...
But how does the other user's app know how to receive it?
I've read about custom UTI types and have declared one, but to be honest I don't know what to put in the declaration. And how do you indicate to iOS that the data you are sending conforms to this particular UTI?
There are AirDrop examples here and there online, but they focus on sharing common types like images, and no one I have found has worked through sharing a custom data type in detail.
Can anyone help?