Cordova Phonegap Local vs. Hosted Cloud App - javascript

I'm wondering what are the pros and cons of having the raw phonegap html files sit on the actual device vs only having a "jumper" page that'll redirect to an app hosted remotely on the cloud.
These are the things that i could think of:
offline access - is much simpler when the html files sit on the actual device, otherwise you'll have to use HTML5 offline API. +1 Local
View Helpers & Embedded Code - Whether building with Rails or Express i'll gain access to view helpers and embedding if i go with a hosted solution, just like when building a "normal" website. +1 Hosted
Rest API - If i keep the files locally i'm forced to create a completely separate API to handle to handle all server communications (unless going with something like StackMob). While this might be useful later on if decide to multiple clients it's probably overkill ATM. A hosted solution would handle server calls the same way "normal" websites would do.
+1 Hosted for simple apps
Any other Pro's and Con's i'm missing?

Normally I would locate the static files on the device itself. Otherwise, you always have to request the files via GET (bad for traffic and performance especially on mobile devices).
When you want to put your app to the Apple AppStore, you have to care about redirecting to an online WebApp only I think you will get trouble with Apple.

Related

Make a game written in Javascript available online

I've just finished a simple game in Adobe Animate using the HTML5 Canvas. I now have .fla, .html and .js files. Can I now put these somewhere on my website to make the game available to play? If so, where? If not, what else do I need? Thanks.
Clicking on the HTML file opens it in a browser, but I can't interact with it.
Thanks.
You're stepping in to a whole new world of hosting and deployments. To have a functioning website you need:
A host server
A domain name
Web files (which you have)
The host server will serve up your web files and allow incoming traffic from the web.
The domain name is optional, but helps with visibility. Without it you'll have to connect directly to the IP address of the host server.
I'd recommend finding a host like HostGator, GoDaddy, or Amazon S3 if you want to host a static website. It can be pretty intimidating at first, but you'll need to put in the time reading documentation to fully understand the process.
Alternatively, if you just want to get it running locally and not on the internet you can install a simple http server on your machine. I use NodeJS so I'll test with http-server alot. Hope this helps!

Is it possible to serve user created content offline in javascript?

My application serves user created bundles of HTML pages for e-learning, also known as SCORM packages, and i'm trying to make that as fast as possible.
Loading page-by-page in iframes is quite slow, as pages may include high resolution graphics, animations, audio, video and so on.
Unfortunately pre-loading these pages is quite difficult, as they usually react to onLoad() events to start animations and interactions.
Without using applets or extensions, would it be possible to download the user bundle and serve it "in-browser" to the application?
This is a common-enough task with the advent of fat clients built on Backbone.JS, Angular, Ember, etc. Clients request data (usually JSON), media, etc. from the server as opposed to pre-rendered HTML, and do rendering and resource management client-side. If you want to go this way so that you can support flexible offline mode the way you specified, you usually need a set of generic loaders and tools in your app cache manifest that will loading the more specific (user-specific, lesson-specific, etc.) resources on page load.
The first time your user opens your app, it should be in online mode, and your app will need to request the specific resources it needs to work well offline and store them in client-side storage (localStorage, indexedDB or what it's trying to replace - WebSQL, and fileSystem. There are many resources on the web on how to use each of these APIs.). This step can also be incremental, rather than a huge download of megabytes of data.
The next time your user opens your page, your app can attempt to load all the resources it needs from client-side storage before even calling the server. It will only need to call the server if it's missing some resources, or if it needs to get a fresher version of a resource, or of course if you need to write to the server. If you did a good job of loading all the resources it needed into client-side storage the first time, it can work decently in offline mode.
If your users are running modern browsers you could use the HTML5 cache manifest.
Creating a manifest file will get the browser to download and store the site locally and then the user may even visit it offline
http://en.wikipedia.org/wiki/Cache_manifest_in_HTML5

HTML/Javascript Offline Tracking Localhost Without Analytics

What I am looking to accomplish is when a website is hosted locally on the localhost if it would be possible to track the clicks/navigation kind of like google analytics does but a very simplified version of having time stamps, and counts using primarily HTML5 and Javascript. I haven't found much information doing something like this with localstorage either. Primary reason is to keep tracking information for what information would be accessed without being online/needing a internet connection.
If I remember correctly one of the issues of localhost, is the inability to have scripts change files on the localhost directly(AJAX) and would require to be sent to a server. Preferred if it did not require server side languages such as php, etc.. Since how this would be used would not always have mamap/wamap installed.
Any help would be great, or a direction.

Deciding an architecture for a titanium mobile application

I am fairly new to the development world. I need to built an app writing javascript on Titanium that should run on iOS as well as Android using a single codebase. I am currently targeting iPhones at the moment. The app is about a shop that is into selling traditional clothes and letting interested people know about the collection that they have. Any idea about the architecture that i should decide. Since it is quite logical that the user will update his collection of clothing frequently how should i go about it? Should i give him the client application that will run on his pc that he will make use of to update his changes? Will Appstore accept such apps? Any other points i need to know as i need to start the development asap.
I think the best solution will be an App with Web as backend. Means you can put the data in Web, and your app used particular URL's for fetching the required data in the form of XML and JSON.
Your app will parse the data and display it on the view.
If there is new images in the server, your app will download it to the iOS device.
Another option is an app which deals with HTML pages. Means you need to display the page on a web view. If you need to update the data, you can update it on the server. Also it can be of two type
Your app will load the page from remote server, using the url
Your app will download the page to iOS device and display it from there, until a new change occurs.
If you are interested in HTML and CSS, PhoneGap is another cross platform, that can also help you.
for rapid devlopment you can use python django... in your case you can use Django-tastypie for backend will be good choice.since using django you can develop it in quick time and the tastypie has api services which can used easily for retrieval and sending data
you can go through this
http://django-tastypie.readthedocs.org/en/latest/

Phonegap: flexible iOS app update (No AppStore)

I have a Phonegap iOS app. My app is distributed privately, hence there is and there will be no usage of the app store. The app communicates with a homebrew middleware. In order to manage the app updates, I thought about doing something like:
-> On app start, check if a more recent version is available.
-> If yes then call a home-made Javascript module that will leverage the HTML5 file I/O API in order to update/create/delete files based on the output of the middleware.
In your opinion; is this solution reliable?
Are there any alternatives? (app store is completely out of the picture)
With a PhoneGap/Cordova app you normally load files from your local www folder. The problem with updating files at runtime is that you cannot write to the www location - you can only write to your app's 'documents' folder.
I assume you are using an Enterprise distribution since you are distributing without the app store. You could look at using something like TestFlight to distribute updates if you are happy for the users to have to go and check for updates.
You could also eliminate TestFlight and host the ipa files yourself, check for updates and then ask the user to download and install the update.
EDIT
It is not possible to write to the www folder with or without a plugin. This is due to iOS restrictions rather than PhoneGap/Cordova restrictions.
These links talk about distributing Enterprise apps over-the-air
http://developer.apple.com/library/ios/#featuredarticles/FA_Wireless_Enterprise_App_Distribution/Introduction/Introduction.html
IOS Enterprise Distribution Through OTA
Enterprise In-House App distribution
I was considering using the www folder as a bootstrap to download the actual app in a www folder in the document directory, and loading the index.html page from there (and the rest of the app)
I'm wondering if that would be an option
Of course the ObjectiveC UIWebView would point to the downloaded version if it exists
I know this is an old question, but the accepted answer is no longer correct. Here's a complete project showing how it can be done: https://github.com/ben-ng/phonegap-air
In short, the trick is to not write to the app bundle, but to the Documents directory.
There's an alternate service called Trigger.io. It is a lot like phonegap, but one of its' key features is that it lets you "reload" the app on the device, which is essentially what you're looking for, AFAICT.
So it seems that cordava can only load files that are in the app bundle. You cannot simply alter the webroot parameter to take the documents folder.
What you could do is use the FileReader API to read from the persistent store. This would mean you would have to create some sort of bootstrap html / javascript that is in the app bundle and create code that loads the content from the persistent store (which you can update yourself anytime you like)
This is a great place to start looking: Cordava File API docs

Categories