I just want to develop an ios app based on webview. The offline storage must be used. I know that html5 offline storage is supported by webview. But I just want to use a native sqlite file(not the one embedded in webkit) just like other native ios app. So could anyone please give me some clues?
Are you implementing the database via javascript? If so check out this great free eBook on building iPhone apps. The chapter about Client-Side Database should give you a running start.
http://ofps.oreilly.com/titles/9780596805784/ch05.html#ch05_id35933084
regards
Andrew
webSQL is available in UIWebViews.
However, if you're using Cordova the convention is to use the SQLite plugin. GIYF.
I personally like using web storage wrappers for this. Lawnchair.js and persistence.js were earlier wrapper solutions, but I like using Mozilla's localForage the most. It makes storing any kinda JS primitive/object/blob really easy.
localForage is just a wrapper over localStorage, webSQL, and SQLite. It has a really simple API and will choose the best web db for you based on what you wanted to store (was it serializable: localStorage. was it a [file Object] from an HTML input: webSQL). Your project can be a Cordova project or whatever. Don't matta. It'll work.
Related
Im new to iPhone development and I find PhoneGap suitable for me for i am a web developer. I'm into practicing database using SQL. because of HTML5 support built into safari browser they support database natively into the browser.
I wonder if theres a good example that is easy to follow of using CRUD into SQL database in iPhone.
After reading your question, I think some points need to be explain:
phonegap
Official documentation & description can be found on : OfficialWebSite
Phonegap is an open source framework / tool to develop cross mobile application. It allows to create mobile applications using only web technologies like html, css, javascript (ajax philosophy mostly used) and get access to APIs & app store.
It provides a wrapper for javascript to access to core mobile technologies like sensor or gps...
You write your web application with phonegap functionnality, and after compilation for each plateform you obtain an native application (webview inside the application runs the application...)
To write the application, you can take advantage of HTML 5, javasvript
The obtained app can be deployed on the application store.
actual supported plateform iPhone, Android, Blackberry, webOS, Symbian and Bada
html5 & storage
One of the functionnality introduced by html 5 is the local storage which permits to manage local storage in your browser with a key-value approach. it could be considered as a super cookie (too much resteictive) and permits to speed up treatment or have an off line access to the application.
Refence
good introduction
for example:
you can write a rss reader which download the news locally and store them tx to local storage. next lanch you just have to do the rotation with old news and if phone is out of network it works always but no update...
CRUD
the html 5 storage could be manipulated with javascript
manipulation sample
I am trying to do web apps using PhoneGap framework for iOS. I need to know whether PhoneGap loads page from server or not, I mean , can I use server side scripting language like php, pyhon, etc?
And if I used those scripting language, can I use phone native feature like camera?
Also for data storage there may be feature, I heard opendatabase can be used for online / offline database. Please anyone help me to figure out these things.
Waiting for good answer.
Thanks
Server side scripts cannot be loaded from within the app, however you can certainly call out to PHP, Python, etc running on a server from the app using AJAX, XHR, etc.
I gave an example in the question below:
How can get value in phonegap which is returned by php class?
I am writing a native iPhone and Android app using Sencha Touch inside Phonegap and my client is very keen for me to include Analytics.
The application needs to function happily offline so I need an analytics solution that can remember activity occurring while offline and updating the server once online again.
My thoughts are to store events from within the JS to a store that can be checked at a regular interval on the device and posted to the server.
My question is whether a SQLite DB could be used for this using the Phonegap API and whether this DB could then be accessed from the native code?
I suspect not and that the best option would be to write to a text file.
Any thoughts or suggestions gratefully received.
The solution to this seems to be to write a Phonegap Plugin that lets you call a method from inside Phonegap to a method in your native application.
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.
I was looking into PhoneGap and Titanium framework, and I did not clearly understand how to they work, let's suppose I have already developed an app for android or iphone, can I run this app on another mobile with a different OS with PhoneGap or Titanium help?
Or I have to develop again my app with PhoneGap/Titanium framwork?
In this case I have full support at all the features like thread, JSON or XML parsing and so on?
Thank you
PhoneGap basically takes a client-side web app (HTML, CSS, JavaScript) and wraps the whole thing in a native device's web view control. You can hook to some of the device's native functions, but as you can guess, it's pretty limited compared to native development. But easy, and brings in a whole range of skills that a lot of people already have. That's really the appeal of PhoneGap.
Titanium is also html/javascript oriented, but it actually claims to compile to native code. Their sample "kitchen sink" app demos quite a lot of the native APIs, at least for the iPhone. I doubt you'd be able to deal directly with threading, but JSON for sure, and I'd think XML as well.
Titanium has full support for JSON or XML parsing.
You can see Titanium examples - Kitchen Sink - for more details.
The idea behind phone gap is that you can take a browser based client app that is written in html/css/javascript and use phonegap to gain access to some native mobile hardware like contacts, gps, accelerometer, etc. Phonegap allows you also to build this web app for different mobile devices all using the same web app code.
To answer the first part of your question, no, you would not be able to take a developed app and use PhoneGap or Titanium to run the app on another device.You would have to write the app in either the PhoneGap or Titanium Framework and then build the application to the devices you want to support through the tools that each give you.
For example, you would write your code in JavaScript(Titanium) or HTML/CSS/JavaScript(PhoneGap), then use the app's build tool to create the file that would be released onto the phone.