0
votes

I am developing a document viewer that handles a custom file type for iOS. Users should be able to open documents from inside the App, even if the files are not saved somewhere in the App's local Directory.
Is there any way to provide my Users with an file-explorer-like structure inside my App?

What I've already tried:
My first guess was to just create my own explorer by using TPath and TDirectory from System.IOUtils and rendering a list of all files and subdirectories at a given Path.
This already worked in the respective Android App and I also got it to run using only paths inside my App's private directory.
Sadly TPath only provides these local paths and I didn't find any other path I could use to browse files anywhere else on the device.

Reading the Apple Developer Documentation I also found out that my problem would be fixed by just using a UIDocumentPickerViewController but it isn't implemented in the iOSAPI, is there maybe another way to trigger iOS to show one?

I am using the following Versions:
Delphi 10.4 Sydney Patch 3
Platform Assistant Server 21.0
macOS Catalina 10.15.6
Xcode 11.7
iPhone 7 with iOS 13.7

1
I have an implementation of UIDocumentPickerViewController in the Kastri library: github.com/DelphiWorlds/Kastri. You'll find a demo in the Demos\FilesSelector folder. It uses units from Kastri, including in the Features\FilesSelector folder. Sorry there's no documentation for those particular parts as yet.Dave Nottage
Thank you, this is exactly what I needed.Martin

1 Answers

0
votes

Have been testing on IOS your FileSelector project. It works just fine, and let me select the file i choose.

The problem im having is when i try to open the file selected or handle it.

I have put the following code on the SelectorCompleteHandler event handler:

var
  Sourcefile,DestFile: string;

  fileman : NSFileManager;

begin
  ListBox1.Clear;
  ListBox1.Items.Add('W');
  {$IF Defined(IOS)}

     Sourcefile := FSelector.Files[I];

     fileman := TNSFileManager.create;

     Sourcefile := Sourcefile.Replace('file://','',[rfReplaceAll,rfIgnoreCase]);

     DestFile :=  IncludeTrailingPathDelimiter(System.IOUtils.TPath.GetDocumentsPath)         
     +'New';

     fileman.copyItemAtPath(NSStr(Sourcefile),NSStr(DestFile));

It works only for documents that are inside the App inner folder scope,but not outside of it (documents, download, etc)

I have set the following permission on my project file versioninfo: UIFileSharingEnabled,LSSupportsOpeningDocumentsInPlace,NSAllowArbitraryLoads

I think is definitely that is a permission issue, but havent able to find information how to set correctly the Delphi project permission need in order to access any file y any location, not just my internal app folder.

The strange thing is that i dont get any error message with the copyItemAtPath sentence.

Regards, Aldo Victoria