If I do something like download a PDF from dropbox, for example, there is an 'open in' option that lets me do things like share the file, open it in various programs, print it, etc.
Seems to be standard Apple stuff.
I am writing a CSV file in my app in Swift, and when complete, I would then like to allow the user to open this file in the same manner as above (letting them attach this to an e-mail, print, open in an app of their choice, etc).
I'm having a harder time than I thought finding the code to do something like this. Any pointers to get me started in the right direction?
Thanks!
You are describing a UIActivityViewController or, for sharing out a downloaded file, a UIDocumentInteractionController.
Related
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.
I am attempting to write a program that looks at the current browser you have open, goes through each tab, and copies and pastes each page's url into a notepad file.
I have no issue with writing the file; my main concern is that I can't find anything in any language that can look at the browser, sift through the tabs, and scrape the url.
Does anyone know if this would be possible, any code that might be able to help (in any language), or if something like this exists? I would appreciate anyone pointing me in the right direction.
The software I was looking for did not exist, so I created it. It's a chrome extension called Raincheck
Is There A Browser-Add-on That Can Create A Temporary Txt File From My Clipboard And Populate The File Submit Dialog?
Guide for firefox:
Get the data from your clipboard with this: paste data from clipboard using document.execCommand("paste"); within firefox extension
Now you can either create a temporary file with something like OS.File: https://developer.mozilla.org/en-US/docs/JavaScript_OS.File/OS.File_for_the_main_thread
Or create a object with something like window.createObjectUrl.
Then assuming the file submit dialog is prompted by a html5 uploader, then you should just set value of that html5 dialog box there are other ways though too, like mozSetDataAt, mozSetFileArray etc, search github for these keywords shows excellent examples:
https://github.com/search?l=javascript&q=mozSetDataAt&type=Code&utf8=%E2%9C%93
https://github.com/search?l=javascript&q=mozSetFileArray&ref=searchresults&type=Code&utf8=%E2%9C%93
You might need to use the mimeType of application/x-moz-file not sure. Definitely experiement with it and share your solution, and ask for help along the way. This is fun stuff.
There are probably other smarter ways to attach into a input type=file, i was trying to do it the other week. I would also be interested if someone else could share some solutions to actually trick the file input element to think the native file dialog was actually used, maybe using XPCOM.
I'm sending ICS files to Blackberry phones, and when you open the mail I get the following error on the phone:
application/X-rimdevicecalendar, that when opened, the BlackBerry smartphone states this attachment type cannot be viewed on your device.
I found in the blackberry knowledge base the problem, but I could not fix it. Does anybody knows how to fix it? How I should send the ICS files?
.ics files are the calendar event files for Apple's iCal calendar software. Some other apps support this file type, but not all ... and some of the ones that do have some problems doing so.
You have at least a couple choices, depending on how these calendar event files are being generated and sent.
you could try sending them as .vcs files instead (and of course, reformatting the content as VCS files)
if you are going to stick with .ics files, take a look at this CrackBerry.com thread
Basically, it looks like there is a workaround, where you might have to programmatically edit the .ics files, and replace this content:
METHOD:PUBLISH
with this:
METHOD:REQUEST
I haven't done this myself, so no guarantees. But, that looks like a promising potential solution that you could try.
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.