5

In the settings screen of iOS I can choose for iCloud Drive enabled apps the "Document Storage" setting (analog to Mobile Data, Camera access options). There it says "Store Documents & Data On" with two options for iCloud Drive or On My Phone meaning locally. enter image description here

How can I access the selected option in my app?

My app is based on UIDocumentBrowser with enabled "Supports opening documents in place" and "Application supports iTunes file sharing". Some apps, like Apple Mail only support the "Copy to" option when pressing the Share button (in comparison to "Open in"). In this case I would like to copy the shared document to the respective directory in my app, so either locally, or to the app's iCloud Drive directory, depending on the user's choice from the General settings.

Right now I base the decision where to copy the document on a check if iCloud Drive is enabled. However it's possible that iCloud Drive is enabled, but the user selected storing on his iPhone (locally).

There are apps in the Store which are based on UIDocumentBrowser and support this. Especially when they offer a create new file function

Thanks!

iOS11, Xcode 10.1

Jim B
  • 641
  • 5
  • 18

1 Answers1

0

There is a way to use "Document Storage" option.

You have to use revealDocumentAtURL:importIfNeeded:completion: function from UIDocumentBrowserViewController when importing a document or other file:

documentBrowser.revealDocument(at: URLToImport, importIfNeeded: YES)

It creates new document at url based on "Document Storage" value in iOS Settings.

More info about revealDocument here: https://developer.apple.com/documentation/uikit/uidocumentbrowserviewcontroller/2915849-revealdocumentaturl?language=objc

Slyv
  • 421
  • 3
  • 8