Launching a native application from a link of website on iPhone - iphone

I have a query regarding launching a native application from a link of website on iPhone.
I will explain.
Generally a web based application is used to work online without using any feature of iPhone device (such as GPS, Camera, Accelerometer etc.)
I have a iPhone specific website which performs many tasks online.
Now while keeping all the functionality same, I want to add a feature of taking a picture from iPhone in-built camera.
i.e. when user clicks a button on website "Take Picture", my native application should be launched, which will take a picture and do specific tasks..
How to capture a event of button click which is performed on website?
Should I use UIWebView or Safari?
I know that using URL Scheme we can launch Safari from native application.
But how to achieve the opposite as explained above?
All other functionality works great on website, so I don't want to convert the whole website into native application.
(Otherwise I will have to deal with web services). Only this functionality needs to be added.

Register a URL Handler, then have a link on your site to myapphandle://some.parameters.here/
A la: http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

Related

iPhone: Access Camera and Album from Web app

I want to develop a web app using html5, js. One of the feature is to launch device Camera and record video, take a picture and access photo album. Is it possible to access via web app if i develop? I saw in the forums that, it is saying not possible in some places and it is possible in some places. I would like to know, is it really possible to access directly camera and album etc. ?
Please suggest!
Thank you!
It's not possible to access phone camera using Web app, as the "Web APP" typically runs in the browser of device.
Though there are some frameworks (like Phonegap) allows you to embedd your web app into native container. With this approach and added libraries from such framework you can access some of those native API's and Device Hardware.
One Possible solution is,
Create one app and distribute it using app store
using your webapp, you can connect to above app using url-scheme
http://code.google.com/p/iphone-photo-picker/
go to above link, where you can find complete code for it.

Is it possible for native iOS application to interact with Safari browser?

I would like to enable interaction between a native iOS application and the Safari browser such that tapping a right click on an image on a webpage provides an option in the context menu to send the image to another custom written native iOS application for further processing and/or storage.
However, according to this article from Safari Developer Library, “Safari extensions are not currently supported on iOS”.
Is there any other alternative to achieve the above functionality?
You have multiple choices here:
You could register in your application's Info.plist file that your app known how to handle certain type of documents (see here in Apple's doc). This way when your iPhone encounters this document type, iOS will propose the user to open this document in your app; for example if you register for the PDF type and you then tap on a PDF document as an attachment in a mail, you app will be listed in the proposed menu and will then be opened with the document as a parameter.
But it seems that even if this works perfectly for any type like DOC, PDF, or even custom types, it does not work for images, which seems to be handled in a separate way by iOS :(
A simpler way would be to register, still in your application's Info.plist, any custom URL schemes. See here and below in the Apple's doc. For example when, anywhere in your iPhone (either in your own app, or in another third-party app, including Safari), it encounters URLs like "myapp://xxx/yyy/zzz", it opens your app, passing this URL as an argument. You can then do whatever you want with this URL.
The solution then is to add some code in your web page so that when the image is tapped, you ask Safari to open the URL "myimageditor://edit?url=http://www.url.of/your/image.jpg". If you registered for the "myimageeditor://" URL scheme, you app will then open with the URL in the parameters, and you then will be able to retrieve the image using the embed URL.
I think it is possible only for jailbroken devices.

Prevent Downloading of Mobile Safari Video

Via HTTP Live Streaming or any other method, is it possible to embed videos in a web page that:
Are viewable in Mobile Safari?
and
Cannot be directly downloaded? (when the user navigates to the media URL in a browser, they should not by default get a downloadable file.)
Flash and Silverlight can serve media that meet these criteria on desktop browsers. I'm wondering if there's some way to meet this criteria that is compatible with Mobile Safari, which does not support Flash or Silverlight. The media need not be impossible to rip, just difficult to download with a browser alone.
For example, on the below site, demonstrating HTTP Live Streaming, I can just open up the video URLs and do File > Save. This is what I (actually the client's legal team) would like to avoid.
http://iphone.akamai.com/
Edit: Tried to clarify my question based on responses so far.
its known fact that anything accessible to a browser is downloadable, otherwise the browser couldn't get it. most users are to busy watching the video to think about downloading it, but if they want it there get it...
#dleavitt:
As per Apple's HIG, It is a fact that an app cannot have control of the things outside its sandbox.
So as the Mobile Safari Browser is not in the sandbox of any of the iPhone/iPad apps, it cannot be controlled. You cannot modify or make any changes into its default behaviour.
So keeping it in simple words, You cannot stop downloading videos via Mobile Safari Browser as you dont have control over it.
Hope this helps you.

Android, Iphone app with JS and HTML

I have read some post about apps programming for Iphone and Android, but I have one question. Is it posible when there is a mobile website optimized for mobile phones, that I can create apps for Iphone, Android, Win 7 and Blackberry, that only statrts the browser as instance and display the mobile website? What do you think, is this ok? Do you have any ideas or examples for that kind of apps? I mean this is not an app, that should be has access to the hardware of the phone, only web app.
Thanks
Nik
This would work.
You could create an app that consists merely of a webview into which you load your content. The content could be loaded over the mobile network or be stored locally.
However most users (including yours truly) strongly dislike apps that merely present a single website to the user, because of the long delays if the content is loaded over the mobile network every time and because the UI is, in many cases, very different to what the he or she is used to from native apps.
Most users fail to see the need for a specialized app just to visit a website which they could as well keep as a favorite in their mobile browser. On the iPhone, you may even add favorite websites as icons on your homescreen, so there is no need for apps presenting a single website at all.
It's not only possible, such things are already done. One example I know of is cookd, a restaurant guide for Vienna. But there are some constraints; for example, cookd requires GPS data for the "Nearby" option; on my Android phone (HTC Legend), this is possible when I open the web page directly in the browser (the browser asks if I want to allow cookd.com to get this info); but the same webpage, running in an application that does nothing more than display the browser component, cannot do that. To fix that, they would have to build GPS reception into the app and forward this info to the browser component.
O'reilly has a fantastic article about this:
http://building-iphone-apps.labs.oreilly.com/
This is a little bit directed to iPhone only, but will give you a good overview about the topic and possibilities.

What are the limitations of coding web apps for the iPhone?

For instance, could a web app access the mic on an iPhone and transmit voice back to a server?
Or is it possible to build Safari extensions for the iPhone that can operate transparently on a web page? For instance, is it possible to build an extension that removed ads from Google result pages for the iPhone, without the user clicking any buttons to activate the ad-removal functionality?
You pretty much hit the main limitations.
You have no access to hardware that's not supported by HTML5 (geolocation is, but things such as acceleration and audio/video recording are not).
You can't build Safari extensions for the iPhone at this time, you can only use JavaScript like usual.
Some frameworks like PhoneGap make attempts to provide more hardware features via a native app container, but it appears Apple is trying to prevent those apps from going on the App Store, to some extent.