How to open native files app in ios?

耗尽温柔 提交于 2021-01-04 07:24:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!