PhoneGap: It's possible to use only the phonegap.js and it's functions only in a Website (doesn't want an App only a Webpage)? - iphone

It seems that I haven't understood correctly how PhoneGap works.
I thought:
Take an index.html, include the PhoneGap.js in as type of JavaScript and open the result on iPad/iPhone.
But then, none of the functions like accelerometer, beep(), vibrate() is working. Is it necessary to build an app for that for working correctly?
I have a Webpage and I want only include the functions of PhoneGap so that the iPad can recognize if it was shaken or a draggable HTML Element was touched and thrown at an other place on screen.
Is sencha able to do that and is it the better choice?
Greetz and Thanks!
Markus

PhoneGap is a native application wrapper for a variety of different phone platforms. It requires that you use the PhoneGap framework, which is written in native code for each supported platform, for whatever platform you are targeting, and allows you to drop HTML, CSS and JS assets into this framework so that you can build applications for a phone with only those web technologies.
Simply including phonegap.js on a web site that is hosted on a server will not work, because phonegap.js communicates with the (native) PhoneGap framework code. The framework code does the work of accessing the phone's APIs for vibrate, accelerometer, contacts and compass functionality (among others). phonegap.js simply provides a consistent API in JavaScript for accessing this native device functionality.

There is no access from Javascript hosted in an ordinary web page to the accelerometer on the iPad as of today -- which is the first piece of functionality that you want to access. If you want to use Sencha (I work for Sencha), you must wrap Sencha code with Phonegap's native shell in order to get access to this functionality. Phonegap takes native Objective C API's and creates new Javascript objects that correspond to these API's. But the result will be a native app, not a web page.
Drag and Drop, the second piece of functionality that you want, is an activity entirely within the browser, and Sencha handles drag and drop just fine.

Related

Can I use third party PhoneGap plugin on a web page using iOS Safari browser?

I am developing an application targeted only for iOS device(for now) using PhoneGap library and HTML5. This application is going to be only a web page accessed through iOS Safari browser. I am going to use certain features like accessing accelerometer, geolocation, contacts etc of iOS device using PhoneGap library.
Will I get access to all these features without installing anything on the device.
I want to understand how does PhoneGap get access to native features
of the device by just using JavaScript only?
I see there are several useful plugins written for PhoneGap library.
Can I simply use those plugins(js files) into my page without
installing anything on the device? E.g PhoneGap ChildBrowser plugin?
Will I get access to all these features without installing anything on the device.
You will have to build as a native ios app and install it to the device.
I want to understand how does PhoneGap get access to native features of the device by just using JavaScript only?
Phonegap provides a Javascript interface to access hardware features which are actually Objective-C functions. If you look at Phonegap source you'll see a lot of Objective-C code. So it's not only Javascript.
I see there are several useful plugins written for PhoneGap library. Can I simply use those plugins(js files) into my page without installing anything on the device? E.g PhoneGap ChildBrowser plugin?
No. They have to be inside an iOS app to be able to work.
It seems like what your after is a way to access the features of an APP only through the browser.
You can access some things using HTML5 e.g.:
Geo location http://html5demos.com/geo
Accelerometer http://menscher.com/teaching/woaa/examples/html5_accelerometer.html
Video Embedding http://www.w3schools.com/html5/html5_video.asp

Is Titanium's HTML5 (and JS) really native?

I'm a little confused about this. Titanium is bragging about being able to style with CSS, program with javascript and create with HTML5, whilst making the final product native to the platform. How is this possible? If I'm writing in JS/HTML/CSS then won't they be run within the browser? Making them non-native?
See jhaynie's explanation of how the Titanium Mobile SDK is used to compile to native code. In essence, the Titanium Mobile SDK creates a mapping between their APIs in javascript and the native APIs of the target platform.
Titanium code are written in core JavaScript and code is then converted into native code(i.e. objective c or java) But when you use HTML and CSS into titanium you need to render them into "WebView" a browser without address bar. So in that sense titanium is completely native.
You code a Titanium Mobile app in js using their API that 'bridges' your code to the native API.
You don't use html/css at all unless you want to include a webview with local content.
It's possible you are looking at old documentation. Titanium used to use HTML/CSS/JavaScript for creating applications which did not use native UIs but as of 0.9 is more of a JavaScript abstraction of a generic mobile device. This means you won't be using HTML or CSS to build your app and the process bears little resemblance to building a web app. Other tools like PhoneGap use the web app model in place of a native UI.
That said, you can create a web view (in-app web browser) in Titanium which you can use to show HTML5 content if you so desire. Also, as of Titanium 1.5, you can also use a CSS-style language called JSS to separate your JavaScript application model from your content.
Apple iOS has a "WebView" which is basically a browser window under control of the program. They take your code, plop it in to a WebView and wrap some infrastructure around it, and compile and ship it as a "native" program.

How can I develop an iPhone app in HTML5?

I have seen a blog which claims that we can develop iPhone applications in HTML5. Untill then I was aware about Objective-C on Mac.
Can we develop an interface with backend support application in HTML5 on iPhone? Will it be secure and scalable?
If HTML5 is a markup language, then how can I make conditional statements in it? Would it be via jQuery or Javascript?
Which IDE should I use to develop an iPhone app in HTML5?
A great place to start when developing an iPhone app in HTML5 is PhoneGap.
You could either go the full-blown app route by developing an iOS app using PhoneGap, or only selecting certain tools/frameworks to help build a web-based app for mobile devices.
And very much like how it works with websites, HTML is used for the structure, CSS for presentation and JavaScript for behaviour. So yes, JS is used for conditional statements, etc.
Yes.
You can develop an HTML5/CSS3/Javascript app, then wrap it in PhoneGap or Apache Cordova to make it native and put it in the App Store (or Android Market...), as well as publish it on the web. You can do this with whatever tools you're comfortable with.
Using a tool like PhoneGap has many benefits over browser-based Mobile Web Apps, such as allowing you to parse iPhone contacts and access the local hardware.
It's great in combination with jQuery Mobile, but since performance is a MAJOR issue you must be very cautious to really streamline your images, CSS, and Javascript.
See this link to learn more about Mobile Frameworks.
I have seen a blog which claims that we can develop iPhone applications in HTML5. Untill then I was aware about Objective-C on Mac.
If you want to write a native iPhone application, then Objective-C is your only option. However, as the iPhone’s web browser has a lot of capabilities (e.g. offline caching), you can develop applications that run in its web browser, as opposed to natively. They can’t access all the features of the iPhone, and they are simply websites (so you need a server to serve them), but before the iPhone SDK was released, Steve Jobs himself described web apps as the way to write software for the iPhone.
Can we develop an interface with backend support application in HTML5 on iPhone? Will it be secure and scalable?
I have no idea what that means.
If HTML5 is a markup language, then how can I make conditional statements in it? Would it be via jQuery or Javascript?
Correct: JavaScript. (jQuery is just a JavaScript framework, and it’s probably a bit heavy to use on current iPhones.)
The HTML5 spec blurs the distinction between HTML and JavaScript by defining the DOM interface for the HTML elements it specifies, and defining new DOM features (e.g. offline caching) that aren’t technically part of HTML. Apple (and other people) have further blurred the term “HTML5” by using it to encompass various CSS features like animations and transforms, which you’ll probably find very useful for making web apps feel more like native apps.

Is there a way to automate conversion of web app to iphone or android native app?

I came across this link:
http://ofps.oreilly.com/titles/9780596805784/
which seems to suggest web app can be converted to native iphone without writing a single line
of objective-c code. But the book mentioned there is outdated now and things may have changed a lot.
Are there open source software that will allow me to automatically convert my web application to native iphone ( or android) application? By the way my web application is html5 canvas based animation application with lot of html and css as well.
PhoneGap doesn't generate native code for you: it creates an application consisting of a WebView and throws your HTML code on it. From personal exerience I can add that the performance is quite slow, on both iPhone and Android, compared to a native app.
jqTouch creates a nice way to access your web application, but the application remains a web application residing on your site, plus you have to use some jquery for styling.
Apparently the only one that actually does generate native code is Appcelerator Titanium. On RhoMobile I never managed to get to the point to actually write some Ruby code because you have to know all the Ruby in he word just to install it on your Mac.
So the verdict was to sit down and develop the app in objective-c.
Have you looked at PhoneGap?
Simple steps to put your html app into iOS native container, without coding:
Download xCode
Download simple web view app from https://github.com/nomtek/iOSWebViewApp
Open simple web view app within xCode
Add your HTMLs to the project file structure
Run your app and voila :)
This approach is good if you don't need access to any phone specific features, just a standard Web View. Loading time will be short as this approach doesn't load any extra libraries.

Web based Iphone / Android app

I am considering developing an Iphone/Android application but I want the information on it to be live and uniform between platforms... Therefore it seemed logical to me to make it web based. I would however like to be able to achieve certain non web based functions such as adding events to the calendar and gps locations on the the mapping sortware.
My questions are:
Can I make a web based
application that does not visually
show in a browser?
Can I add additional functions that
are not natively available in a
browser e.g <a href="#"
title="adddate:110911"/>Add to
Calendar</a>
Would it be a lot of work to make
such an app as the majority is web
based (I mostly progam in PHP so
coding for Android and Iphone will
take me some time to get my head
around).
All of the questions are for both Iphone and Android.
Thanks
I would recommend using a cross platform solution like phonegap (with UI sencha touch on top of it).
You can have an app that is a thin shell over the system browser, and exposes the non-Web bits of functionality to the contained HTML via JavaScript interfaces. You will still need two different codebases for iPhone and Android, but the essense of the app will be still webby.
There's no way to manage the system calendar from Web apps neither on iPhone nor on Android, AFAIK.