UIActivityViewController: Changing default file name

When I use UIActivityViewController to share a PDF file (or save it to the file system) the default file name is: PDF document when saved to file or something like PDF document-3A147CA34B5F when air dropped.

Is there a way I can change the default file name? Can I set the default folder when using "Save to files"?

I am using:

struct PDFSaveController: UIViewControllerRepresentable {
// https://stackoverflow.com/a/58341956/16675319
var activityItems: [Any]
var applicationActivities: [UIActivity]? = nil
func makeUIViewController(context: UIViewControllerRepresentableContext<PDFSaveController>) -> UIActivityViewController {
let controller = UIActivityViewController(activityItems: activityItems, applicationActivities: applicationActivities)
return controller
}
func updateUIViewController(_ uiViewController: UIActivityViewController, context: UIViewControllerRepresentableContext<PDFSaveController>) {}
}

Save the file to the bundle

let DocumentDirURL = try! FileManager.default.url(.. )
// Now the file itself. Create the name
let fileURL = DocumentDirURL.appendingPathComponent(
name, // <-- New name of file
isDirectory: false
)
// Create the file
if !FileManager.default.createFile(
atPath: fileURL.path,
contents: nil,
attributes: nil
)...
if let fileHandle = FileHandle(forWritingAtPath: fileURL.path){
// Write file using fileHandle
}

Then share the fileURL it will have the name

UIActivityViewController: Changing default file name
 
 
Q