How to open a document in other specific app - like Safari does it with iBooks when viewing a PDF - without using UIDocumentInteractionController? - objective-c

If you view a PDF in Safari, it will show button in the toolbar that reads "Open in iBooks".
As far as I know there is the custom URL scheme "itms-books:" for iBooks and that allows passing a file path. iBooks then seems to be able to copy the file from the source app (from anywhere, or only from the personal documents folder?).
How does this work? The only way I'm aware of to share documents with other apps is via UIDocumentInteractionController, but that that is tied to the default popup.
Is there a way to transfer files using a custom URL scheme like iBooks does?
Or is this some hack only Apple is allowed to use (private API)?
Another way I could think of is to render the controller off screen, loop through it and touch the correct target app by code. Sounds dirty though....
Please note that my intention is not to open something in iBooks but in another app somebody else implemented (that app would be registered for the file types I offer and maybe have a custom URL scheme if required).

Related

Library or API for file browser view?

I would like to implement a file browser view in my application so users can open files using a side panel similar to the browsers in XCode, Text Wrangler and some other programs.
Before I go off implementing another one of those browsers from scratch, does anyone know if there are existing libraries or APIs that already does this?
Google doesn't turn up with much and most of the searches point me to NSOpenPanel which I believe doesn't do what I want.
Thanks in advance.
The Cocoa class that is used to display hierarchical lists is called NSOutlineView.
Outline views provide several configuration options to adjust the appearance.
The content can be provided by implementing a data source protocol or via Cocoa bindings.
Apple has some sample code online that should get you started (it's a file browser - so maybe you can use larger parts of that sample):
https://developer.apple.com/library/mac/#samplecode/SourceView/Introduction/Intro.html

UIWebView disable location prompt

Is it possible to disable the location prompt (or auto decline/accept it) that pops up when you visit certain websites that ask for locations? I am not using a MKMapView because my app will be not be just viewing maps (it just may visit websites that might have maps on it).
I'm guessing since the prompt is not being controlled by my app, but by the iOS system, I probably will not be able to auto decline/accept the dialog.
As far as disabling the prompt from within an IOS app while loading a UIWebView, it is possible.
You will need to intercept the html before it gets loaded into the UIWebView then find which part of it triggers the GPS/Location Prompt. Once you found it, you simply remove it from the html then feed the html into the UIWebView thus 'disabling' the prompt. However, as a result, the webpage will be missing that element.
No, it's not possible to do that. Not with UIWebView, not with any iOS browser.
I know no way to prevent the prompt, I hope it will be implemented as a property of the UIWebView.
The dialog is not there for the safety of the user, when it comes to UIWebViews. The app containing the view has already asked for locations access, and it can be enabled and disabled on settings. To ask for location access both from the app and from the web view, I would regard as a bug.

UIWebView opens safari on load

I have a UIWebView in my application. If I tell it to open the url #"http://twitter.com/" it open in that same webView fine. But if I ask it to open a url like (similar to the one I need it to open): #"feed://www.OcataCore.com/rss/news.xml" it opens up safari as soon as the view that contains the UIWebview is loaded. Is there a way i can force that url to be opened in my webview ?
UIWebView does not offer the same range of features as Safari does. Except html, UIWebView is capable to read the formats listed in this Q&A. It appears like it is not capable of displaying XML, no matter if it is taken from a feed or a local file.
agreed, should not be able to open XML files.
hope this helps though if you are just wondering how to open Safari. use this delegate method of UIWebView to open the links.
webView:shouldStartLoadWithRequest:navigationType
that should work.

Add 'Open With' to own app

I am currently developing an app that has to be able to share documents between two apps. A PDF file will be openend in my app and has to be sent to another app, Pages for example, to make changes to it. From there I can send the file back to my own app if the second app supports it. Now I have been able to register the file types for my own app, and it is showing up and opening files from the second app.
The problem I'm having is adding an 'Open with' option to my own app. Apple's documentation only seems to cover assigning file types to your own app, but not how to share files with other apps. Can any of you point me in the right direction?
You need to use UIDocumentInteractionController explained here and maybe this link will help link too.

How to access Local file system using Silverlight 4 (Webbrowser control)

Our Silverlight application needs to show to the user previews of HTML pages it generates dynamically, so we want to use the WebBrowser to show these pages. The problem is that the HTML contains links to other local files such as images, flash objects, CSS and javascript files. The CSS and javascript could be placed inline in the HTML, but I haven't found a way to embed images. Something simple like this just doesn't work:
Creating the HTML file and the image file in the isolated storage is doable, but I can't get the path to the created HTML file to pass on to WebBrowser.Navigate(uri).
Reading the contents of the HTML file and calling WebBrowser.NavigateToString(string) will show the page, but not any linked images or scripts.
Linking to online sources is not an option as the application needs to work offline (i.e. out of browser) and performance would be much better if the images and flash objects were able to be cached locally.
So, is there any way in Silverlight of showing in the WebBrowser control a local HTML file that contains an image from the local file system, or is it impossible?
Thanks, sandeep agrawal
The only way to make that work is to make the Silverlight an OOB application, and then you can still only access the My* folders.
I heard that someone wrote a browser control that can be used without going OOB but not sure about that. This is a real pain, but a necessary one I guess.