WKWebView File System Browser - ios

I've been asked to add a file browser to an existing Objective C application that uses a WKWebView to load up a Javascript internal app.
Currently we have the capability of looking at the pictures on device to upload images into the app, but I've now been asked to do the same with more generic file types, specifically PDFs.
What I've read so far is that this is only possible if a file is stored in a specific part of the file system and only if the app knows exactly where the file is to begin with, but what I need is the capability to browse to a certain degree.
What I'd like to know is whether this is possible and if there is a good place to start on that?
Thanks.

Related

iOS Share PDF from Adobe Reader

I'm newer to iOS development and I find the file system to be difficult to work with. I've got many cases implemented in my app to share pdfs from browsers and the files app, but when i try to share a pdf from adobe the shared url to the resource looks like:
file:///private/var/mobile/Containers/Data/Application/EB6B8570-6422-49D8-BCBD-C68B9CBCF3C9/tmp/BBTempFileManager/sharedcopies/C2FB25ED-1414-49F0-8953-FFF3A4F6C76C/Sky.pdf
I have a shared container set up that I can already successfully read and write to during other scenarios. Any ideas why the system believes the file does not exist in this location? It appears maybe I just don't have access? What entitlements/permissions should be set up to explicitly allow for this?

iOS local file access and webkit

I'm absolutely new to iOS App development (I haven't actually started yet, still in a design phase).
The task that I have to accomplish with my app is to download a zip from somewhere, extract anywere to local storage and display its content (html pages with javascript) in a embed webkit widget.
The questions are:
1) Will my app have access to any folder of my iPad storage memory?
2) Will my app's embedded Webkit widget be able to display local html pages (like file:///somewhere/over/the/rainbow.html ?
3) WIll that local page be able to use Ajax method (over httpxmlrequest) to dynamically load external scripts or xml (also locally stored - ie ./something.xml)?
Thank in advance for any help!
No it can't access any file. Apps are sandboxed on iOS. You can only access the app bundle's content and documents folder (a writable area unique to your app).
Yes - provided said content is in the areas mentioned in (1). This is how Phonegap-based apps work.
Yes - they can. We've done exactly this extensively in several of our apps.

Download FTP directory contents to ios

I have a website, let's say it's "http://www.jwilkthings.com/stuff"
I have a bunch of .txt files stored on this website, i.e. "http://www.jwilkthings.com/stuff/text1.txt"
What I'm wanting to do is find a way in iOS to download all of those text files without knowing what the document name is. I can already retrieve them manually as long as I have a file name, but I would rather just get all of them at once and put them in the documents directory if possible. I currently use FileZilla to upload all of the text files, so I can use FTP if needed.
The correct way to solve this problem is to not use FTP (riddled with performance and security issues), and to configure your web server to expose a table of contents directory listing that your client can parse.
But that's not an answer to your question.
If you really want your iOS app to speak FTP, take a look at the SimpleFTP sample project from Apple.
It's old, but I just got it to build on iOS 5. The ListController.m file has the code you're looking for.

Custom file types with iOS Document Interaction Programming

I understand the basic of Document Interaction Programming and UIDocumentInteractionController and I've got it working in my app. However I'm having trouble with specific details of using custom file types. I can't find this addressed in the Apple docs anywhere.
My app uses it's own file types with unique extensions. The files themselves are just plists (xml), but I want the device to treat the files as only openable in my app. Originally I implemented the Document Interaction stuff to treat them as XML while I got it working, but now I want it to treat them as binary files that it needs to hand off to my app.
At the moment, if you have one of my files in an email attachment, iOS first shows the QuickLook (which just spews all the text content of the xml out) before you can choose to Open In. Similarly if one of my files is opened with Safari, Safari just shows the XML and doesn't give you the option to show it in my app at all.
So how do I get iOS to not treat my files as XML? I've changed the "Conforms to UTI" value and "public.mime-type" value in the info.plist, but it seems to have no effect.
Any tips greatly appreciated.
As far as i understand the UIT concept of Apple you cannot just change the file extension to change a potential UIT of the file. If the file contains XML-Data, other apps as well as internal apps might recognize your content and show it internally as XML.
Try to store your Plists with NSPropertyListSerialization NSPropertyListBinaryFormat_v1_0 (then you readble XML)
When you did that without success, why not trying this:
use zlib to compress the XML plists afterwards to a zipped file.
make a "unique" file extensions (<file>.myappname)
this should "hide" other apps and quick view.
Tell me if one of the ways did work for you.

How to list my application when you try to open a PDF in email?

I wanted to list my application in the list of other readers installed in the iphone when I try to open the PDF from the email. What settings do I need to do on my project so that my application is also listed in it.
Are you looking for Implementing Support for Custom File Formats?
Applications that are able to
open specific document or file formats
may register those formats with the
system. When the system or another
application needs to open a file, it
can hand that file off to your
application to do so. In order to
support custom file formats, your
application must:
Register the file types your
application supports with the system.
Implement the proper methods to open
files (when asked to do so by the
system).

Resources