Bob van Luijt
Bob van Luijt

Reputation: 7598

HTML5 and javascript in xcode

I'm quite new to xcode, because I mostly work with JS and HTML5. I've decided to create a simple webview app that enables me to work with JS and HTML5 (going to put it on Github asap)

Now my question is about accessing certian iPhone features that I cannot use in Safari or Chrome (the reason why I'm creating this). So the question is: is this possible? for example, I can't access the camera (as a fullscreen background I mean) in an iOS browser, but can I use it in webview?

Upvotes: 2

Views: 5944

Answers (3)

daniel.gindi
daniel.gindi

Reputation: 3496

You need any method of communicating between UIWebView and the containing app. There are libraries out there that do just that, some better some less. In case you do not want them... So to outline the techniques to do that:

  • App talking to the webView - using [webView stringByEvaluatingJavaScript:...]
  • Webview talking to the app - using url directives. Which is essentialy window.location = ... with custom fake urls, and then parsing the NSURLs in the delegate method webView:shouldStartLoadWithRequest:navigationType: and of course returning NO to prevent actually navigating to your fake urls.

If you find that you are missing consecutive URL requests, you could write a JS function that takes the URLs, puts them all in an array, pops one by one and sending them to the browser in a setTimeout(..., 0).

Upvotes: 2

hcarrasko
hcarrasko

Reputation: 2352

Yes, is it possible, but using a web app container like Phonegap.

If you need more info how install it visit this web.

Upvotes: 2

Nitish Dhar
Nitish Dhar

Reputation: 2312

You need to use something like this - Cordova or PhoneGap ( Both are the same thing )

"Apache Cordova is a set of device APIs that allow a mobile app developer to access native device function such as the camera or accelerometer from JavaScript. Combined with a UI framework such as jQuery Mobile or Dojo Mobile or Sencha Touch, this allows a smartphone app to be developed with just HTML, CSS, and JavaScript."

Here is a description of all the device features cordova or phonegap allow you to use - Plugin API's

Upvotes: 2

Related Questions