Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open native files app in ios?

How do i open the native files app of ios using url scheme or some other way ? I tried searching url scheme but had no luck.

There seems to be no answer to this question there is thread open for this question in apples forum but it is still unanswered. https://forums.developer.apple.com/message/257860#257860 Can it be done using the bundle identifier ?

like image 289
Nikesh Hyanju Avatar asked Dec 14 '22 18:12

Nikesh Hyanju


2 Answers

Please try to use UIDocumentPickerViewController for your use case

let controller = UIDocumentPickerViewController(
    documentTypes: ["public.text"], // choose your desired documents the user is allowed to select
    in: .import // choose your desired UIDocumentPickerMode
)
controller.delegate = self
if #available(iOS 11.0, *) {
    controller.allowsMultipleSelection = false
}
// e.g. present UIDocumentPickerViewController via your current UIViewController
present(
    controller,
    animated: true,
    completion: nil
)

UIDocumentPickerDelegate delegate methods to receive chosen documents URL as callback:

@available(iOS 11.0, *)
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
    // do something with the selected documents
}

func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
    // do something with the selected document
}
like image 133
christopher.online Avatar answered Dec 31 '22 01:12

christopher.online


There is the option to open the Files app at a specific location using the shareddocuments:// URL scheme, as described in this article.

If you want the user to select a document, you can use chriswillow's approach with the UIDocumentPickerViewController. If you want to present the documents or folders in your app, create a Document Browser App.

like image 28
Tobias Zucali Avatar answered Dec 31 '22 03:12

Tobias Zucali