Home:ALL Converter>How to send big files using AirDrop in UIDocumentInteractionController

How to send big files using AirDrop in UIDocumentInteractionController

Ask Time:2019-01-15T18:52:35         Author:bholveck

Json Formatter

In the iPad app I'm working on, I'm generating png images that are supposed to be saved or shared using a UIDocumentInteractionController.

Every option works well but one. In the case the png file is bigger than something around 20MB, then the AirDrop functionality fails and the UIDocumentInteractionController popover is terminated by iOS with the error :

viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}

The app keeps running and I can still use it.

In this case where the png file is big, all the other Share/Open In... options work well. Only the AirDrop sharing feature fails.

It happens almost immediately after tapping on the person/device to share to. Thus it doesn't feel like it could be a memory issue. I'm also not convinced about that as I am working on a 2018 iPad Pro that has 6GB of RAM.

In my tests most of the generated files are around 100MB which is not huge compared to what we can transfer using AirDrop from Apple's apps. For example, I've transferred files bigger than 300MB from the Files app using AirDrop.

Note that I don't know the right limit value but I sense (!) it is in the 20MB area. I've tried with files that weighted up to 10MB without any trouble.

I've also tried using UIActivityViewController and got the same exact behaviour. I've tried it with three ways of setting the items to be shared :

  • Setting the png file url as the item
  • Loading the png data into a Data object and setting this data object as the item
  • Loading the png data into a UIImage and setting this image as the item

Here's the code I'm using to present the documentController :

func presentDocumentInteractionController(for fileUrl: URL) {
    documentController = UIDocumentInteractionController(url: fileUrl)
    documentController!.delegate = self
    documentController!.uti = String(kUTTypePNG)
    documentController!.name = fileUrl.lastPathComponent
    documentController!.presentOptionsMenu(from: shareBarButtonItem, animated: true)
}

The documentController var is a member of my class to avoid it to be deleted when the function ends and then avoid the app to crash on nil value.

I have no idea other than filing a Radar to Apple. Anybody has experienced this kind of behaviour?

Author:bholveck,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/54197422/how-to-send-big-files-using-airdrop-in-uidocumentinteractioncontroller
yy