问题
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 ?
回答1:
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
}
回答2:
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.
来源:https://stackoverflow.com/questions/48851246/how-to-open-native-files-app-in-ios