How to create javascript interface for ios application obj-c? - javascript

does anyone know how to create a javascript interface in iOS that can be called from javascript? My aim is to save data from a website in a native fashion and not using html5 local storage.

If I understand correctly, what you need is a mobile webapp packaging solution.
The most popular here is, perhaps, PhoneGap, it supports many platforms including iOS. The product is free and open source. You will still need to use Apple's iOS platform SDK and have a developer account. As for storage mechanism, I believe PhoneGap has a solution for it (allowing the storage to be persistent, not cleared out like browsers' localStorage).
If you want to simplify your deployment process, you may want to check out appMobi, they build on top of PhoneGap, providing their own development kit and cloud deployment services.
Also refer to this thread that discusses different kits:
Comparison between Corona, Phonegap, Titanium
UPD. Have you tried the PhoneGap SQLite plugin for storage?

Related

Does Intel xdk / Jquery Mobile work with Parse.com?

If I build a cross-platform app using the Intel XDK or jQuery mobile, would I still be able to use Parse.com as a back-end to manage data in the cloud and push notifications?
Short answer is yes, but only up to the point, and to make it clear, I'm talking from jQuery Mobile perspective.
You application will use Parse.com REST API for communication but that's about it. Because you are creating a hybrid mobile app RESTFul (AJAX) connection is only viable solution.
You can of course go for some native solution, using Java (Android) or Objective C (iOS) but you will need to write your own wrapper code that will communicate with JavaScript. This is a bad solution because it brakes the point of hybrid mobile applications (One solution to rule them all).
To incorporate everything you will need Cordova (PhoneGap) as mobile app wrapper. From my knowledge, Phonegap plugin is still no go, so you will need to create your own implementation, which will not be that hard, if you take into account that Phonegap plugin for classic push notifications exist, and you can use RESTFul communication to feed it data.
Also, why limit yourself to those two frameworks? Faster, more native like frameworks exist, so choose wisely (find more information here). Application speed if your first and major concern.
Leave me a comment if you need more information.
Yes, Intel XDK is an HTML5 Development Environment to develop HTML5 Mobile Apps, you can use any HTML5 framework like jQuery Mobile and use Parse.com for back-end for data, for push notification you will have to install Cordova plugin, which is currently not supported in the current version, but will be available soon.

Javascript and Sqlite

I am creating an app using HTML5 and Javascript. This app will be compatible with Windows and iOS 6 (iPad). I need a local database access using javascript. This is a pure offline ap with no server side involved.
My dilemma is -
WebSQL is not supported anymore by W3C.
IndexedDB works with Firefox but not with iOS6.
Most importantly, I want to avoid HTML5 Local database storage as it cleans data whenever history is cleared.
I would like to have a durable database locally for the app, something like SQLite. Is it possible to access SQLite using pure javascript, so that it will work with Firefox on Windows and also on iPad.
EDIT: The app will not be run from the browser in iPad (iOS6). Rather the app will be packaged into ipa file and installed in the iPad device.
What you're looking for is a polyfill.
According to HTML5 Please, IndexedDB Polyfill implements the IndexedDB APIs over WebSQL. (The author of the polyfill also wrote an article on Mozilla Hacks about it.)
Facebook also as a polyfill. According to this pull request (to another project), Parashuram Narasimhan, the author of the first polyfill, seems to prefer the Facebook polyfill and is considering retiring his own project. (But then again, the Facebook repo looks like a one-time code dump and may not have any ongoing development.)
There are some points to note.
Its a pure client side app.
Not using webstorage (local and session)
The options left are using webSQL, IndexedDB, Third-party framework or custom solutions.
webSQL :- Support is limited to webkit browsers and w3c declared its dead. Browser support
IndexedDB :- Supports in IE10, chrome and Firefox. Browser support. Not supported in older versions of IE.
Third-party framework :- sequelsphere is a platform independent solution to address this issue. It is a RDMS written entirly in javascript and make use of webSQL or IndexedDB.
custom solutions :- Supporting both IndexedDB and WebSQL on a cross platform web app like this tutorial, we can create our custom cross-browser db solutions or may use lawnchair like json storage options.
We had same issue and got answered on this thread.
Lawnchair is a good choice if you need a single table DB - we had requirement of multiple tables, so have developed own wrapper.
Create a web app using HTML-5 and JavaScript, so that it can work for both desktop browser and
iPad. Make it hybrid using PhoneGap for making it iPad's native app.
Please check whether this might be helpful. you can use javascript for both front-end and back-end (for db interactions). There are so many plugins also available to use for this framwork. http://www.nodejs.org
It's 100% possible. I can recommend a javascript lib for data access in html5 sqlite.
Documentation & sample code: click here
I have made a android demo (by using phonegap) with that lib. It works great!
Download the demo here

Does it make sense to use Cordova or PhoneGap for the development of a pure browser-based web application?

At first glimpse Cordova and PhoneGap exist primarily for the use to develop apps to be used on a mobile device. Well, I am not interessted in the developement of native mobile apps.
There exists a webapplication (a cms) of our own and the question is now if a mobile toolkit like Cordova or PhoneGap is able to be of any help to develop parts of our cms functionalities with it in order to be able to support more plattforms.
Does it make sense to use Cordova or PhoneGap for the developement of a pure browser-based web application?
Phonegap (or Cordova as its now called) works by wrapping your webpages in a Webview and giving you access (in JavaScript) to some of the native device functions, such as the Camera, Accelerometer, Contacts etc.
As for whether it will help you depends on if want to make use of any of the native device functions, for example if you think incorporating the Camera (current HTML support for camera is quite spotty) into your web app is of use then you probably should consider it.
Another consideration is how your users will access the applications, with Phonegap it gets packages into a native app and they can just launch it from their home-screen (or however they launch apps on their mobile device), while with a Web App it depends on the device, on iOS you can pin it to your home screen and add some meta tags to make it appear more native like (for example hide the address bar) while on Android as far as I know you can't do that.
Finally consider that with Phonegap it might be more of a pain to debug your application since your HTML/Js is wrapped in a Webview, but as far as I've seen there is no easy way to debug it there.
One other thing I seem to recall reading somewhere that on iOS Apple doesn't give your native applications' Webviews access to the same amount of memory as if it were in safari so the exact sane web application when packaged into a Phonegap application might actually be slower.
To sum up, the benefits of wrapping your application in a Phonegap wrapper are access to native device functions and how your users access your app, if those aren't important (or the cons outweigh the benefits) than it probably isn't worth your while to go that route.
Cordova/Phonegap extend javascript with functionality provided by mobile operating systems. Therefore apps developed with these frameworks must be compiled to the target platform and only embed the HTML etc. in an embedded browser. The extensions need java, objective-c etc. code to run so I don't think that you are able to benefit from this code.
You are forced to write your own mobile device compliant HTML code when using Cordova/Phonegap. There are no neat mobile device ready user interface controls provided by the framework but only access to device specific hardware or software apis like notification etc. is given.
Cordova is just the latest name of PhoneGap. I would not go for that if you just want to build a mobile website. First of all publishing such an app on several online stores (iTunes, Play) is a pain.

Cross-platform Mobile App with HTML5

I was asked to provide a tablet application with HTML5/JS/CSS which does not have dependency on any platform. Requirements:
Cross-platform mobile/tablet application
Offline capability and Storage (it should work in lack of internet connectivity and be able to synch after get connected)
Real-time data (it should be able to show any small changes from sensor values)
I should be able to connect to a CAN interface and get sensor values and ECU data. Because I have not come up with any solution for this part, I am thinking about Bluetooth. However, HTML5 doesn't support Bluetooth.
I'd appreciate to give me some vision if HTML5/JS/CSS can deal with this requirements (especially with Bluetooth)
Another question is that is it possible not to use any frameworks such as PhoneGap, RHoMobile, .... and just develop cross-platform app with raw HTML5/CSS/JS and have all requirements?
Have you looked in to PhoneGap / Cordova yet?
You can easily create cross-platform mobile applications using HTML5, JS and CSS.
http://phonegap.com
The built-in API provides access to most of the device's native features and functions. You can manage offline storage using localStorage or SQLite databases, and can detect network connectivity statuses to determine if you are offline / online and what level of connection you have (Edge, 3G, 4G, WiFi). With a combination of those, you could manage your data synchronisation.
As for bluetooth, the PhoneGap API doesn't support it out of the box, but it is highly extensible so developers can create their own plugins for missing or required functionality.
The community is awesome and many of the plugins have been compiled into a central repository on GitHub: https://github.com/phonegap/phonegap-plugins
I know that there is a Bluetooth plugin for Android available on that repository.
You can also write your own plugins quite easily to add any extra features that you need:
http://www.adobe.com/devnet/html5/articles/extending-phonegap-with-native-plugins-for-android.html
http://www.adobe.com/devnet/html5/articles/extending-phonegap-with-native-plugins-for-ios.html
** EDIT **
You posted an amendment to the question afterI'd written this answer mentioning PhoneGap. The honest answer is no, without a framework that interacts with the native device functionality, raw HTML5, CSS and JS would not be able to deal with bluetooth etc.
No, you cannot. A pure web application is not able, and will likely never be able, to use bluetooth.
HTML5 Bluetooth and Audio
Having developed a Web App before, I can tell you that anything involving offline has to be simple, and using device hardware is out.
Check out the frameworks, you may be able to get something to work. But it may just be a better/more realistic bet to develop a Native Application from the get go.
After a lot of searching I came up with MoSync which is a cross-platform SDK and is intended for developing different mobile applications. I believe MoSync can be the best answer for this question since it is really a rich SDK (C, C++, HTML, JavaScript) and has great tools and community that try their best to help you.
For further information I encourage developers to check here or visit their websites.
Most of the future mobile apps will be developed using HTML5. HTML5 standards are getting adopted very rapidly and those standards are supporting phone features like GPS, Accelerometer, Camera, Storage etc.
I will recommend you to use PhoneGap if you want to use any device features.

Mac Store Apps: written in JavaScript

Question
I have a HTML5/JavaScript app. I would like to submit it to the apple store.
Is there anyway I can somehow embed this in Safari/Webkit, and have apple accept it as an app?
Context
This project started out as a web app, but I've found I like javascript/SVG far far more than Objective-C. And thus, I'd prefer to keep my development in JavaScript, but yet somehow be able to submit to the apple Mac store.
Clarifications:
I'm aiming for the Mac store, not the iOS stores.
Thanks!
This is what phonegap is all about. Take a look at http://www.phonegap.com . It is an open source project for writing cross plattform mobile apps in html5 which can be run on many different plattforms.
There is a port out there called phonegap-mac which is for the apple desktop. (see: https://github.com/shazron/phonegap-mac)
I have used it several times to host html5 apps as an "app" on mac desktops.
I am not aware right now if there are any restrictions for the app store for desktop apps not allowing phonegap, but in general there should not be.

Categories

Resources