Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open iOS 11 Files app via URL Scheme or some other way

My app is now sharing Documents directory on iOS 11 Files app "On My iPhone" section.

(Thanks to this article: Working with the Files App in iOS 11)

Question is how to open this directory or at least File app root page via URL Scheme. UIDocumentPickerViewController or UIDocumentBrowserViewController doesn't help in this situation.

like image 215
Shingo Fukuyama Avatar asked Sep 30 '17 05:09

Shingo Fukuyama


1 Answers

    guard let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first,
          let components = NSURLComponents(url: documentDirectory, resolvingAgainstBaseURL: true) else {
        return
    }
    components.scheme = "shareddocuments"
    
    if let sharedDocuments = components.url {
        UIApplication.shared.open(
            sharedDocuments,
            options: [:],
            completionHandler: nil
        )
    }
like image 116
David Vatlin Avatar answered Oct 18 '22 17:10

David Vatlin