Cordova web server with configurable responses - javascript

Is there any way to set up a local web server in a Cordova application such that I can control the responses via Javascript? I'm currently developing a custom plugin that communicates with a remote system via HTTP. I'd like to be able to run integration tests on this that are written in the Javascript code of a Cordova application, so I can easily test them in all supported platforms (Android, iOS, and ideally in the browser too... although the latter seems a little unlikely to be possible), but this means I need to be able to set up mock API responses from javascript code ... which will require the presence of a mock server that the plugin can communicate with.
I'm familiar with this plugin, but it can only respond using files in the local system -- I want to be able to generate responses and capture sent POST data in a Javascript callback. Is there any existing way of doing this?

Having searched extensively, I came to the conclusion that no such plugin exists.
I have therefore started an implementation of such a plugin myself: the initial version is now available on NPM and GitHub, with a sample project available in the github repository.
Android support is currently functioning, and I intended to start on iOS support in the next few days.
(Updated to add: unfortunately the project I was working on was cancelled, so have not had time supported by my employer to finish the iOS version, and as I don't have a mac personally so can't work on this on my own time, this seems unlikely to happen in the near future, but if anyone else needs it, it should be relatively simple to add the iOS version)

Related

Do I need to check for localStorage support when using Electron

I have started making desktop apps with Electron.I need to save some configuration into localStorage.I am using the latest version of Electron and I know that localStorage is supported.
Due to my previous experiences with my website I know that I have to check for localStorage support before doing something.
Do I need to do the same in Electron apps?
No you don't - Electron is based on Chromium which has LocalStorage support for a very long time now.
Side note
In Electron, you can also read/write actual files using the file system which might be a better alternative for storing config files.
Since Chromium is not sandboxed when running in the way Electron runs it, you could also read/write actual text files just as you would in Node.js - This question explores those alternatives - or just go straight to using electron-config

Can a web application be converted to a google chrome application?

We have a very simple digital signage application that loads six web pages and rotates through them in an iframe.
We thought we would like to take this application and run in kiosk mode as a chromium app. However, simply using the HTML in the page has thrown all kinds of errors for the app. The most consistent on is the illegal use of external images, css, and fonts as well as complaints about javascript libraries, etc.
It looks as though it will be extremely painful to try to make this into a kiosk app.
Is it possible to make this type of conversion?
Does anyone have advice as to how to proceed?
Can you pull in external pages into a Chromium app?
You cannot run Javascript on a browser via local filesystem for security reasons. But what you could do is package the web app as a local app.
One option is to use Windows HTML Application (HTA)
http://en.wikipedia.org/wiki/HTML_Application
But this requires Internet Explorer to run.
Another option that sounds great is using Node Webkit. I have never done it before, but seems very powerful.
https://www.npmjs.com/package/nodewebkit
You can write a powerful Javascript app and run it locally this way.
UPDATE
Official Node Webkit website:
http://nwjs.io/

Protecting Apps with Apache Cordova MS VS Extension on App Stores

Just have a question about apps that are uploaded on the Windows Store, Andriod Store, and Apple Store. I have never built an App before for any of the three stores, but the Multi Hybrid Extension for Visual Studio seems to be a great start to cover all three Platforms.
How do I protect my code for apps that are uploaded to the three stores? The core development for the Apache Cordova extension is done in HTML5 and Javascript. On a regular HTML / Javascript website, the end user can simply right click and View Source of the page and see all the code I've written.
My question is, how is this protected for apps that are uploaded to the app store? Will someone be able to reverse engineer my application and get the code and simply re-sell it?
Thank you all for your time
You want to, develop once, deploy many. Then, you’ll want to use HTML5 to do it.
You can use Apache Cordova directly, but you’ll want to use a service like Telerik AppBuilder, Adobe Phonegap or Intel XDK.
Regarding your question, your best bet is to use a good JavaScript source code obfuscation service to protect your sources before publishing. There is no such thing as a 100% full proof solution when it comes to JavaScript obfuscation, but professional tools such as JScrambler can take you a long way. At least JScrambler I know that it supports Mobile and HTML5, which is good because they make sure the resulting code is compliant.
There are other tools, even free ones. But be careful though, there are tons of other tools that do obfuscation, encoding/packing or minfication that seem to provide protection, but are reversed in a few minutes. So, unless you really know how to tell the difference, I recommend that you rely on a professional service.

Deploying Web APP (Client side) as Desktop Client

i am looking for an option to fully deploy the client side AJAX app written in js using qooxdoo framework.All view logic stays at Qooxdoo JavaScript framework. But i want to deploy it as desktop client too.
It already hosted on server and working fine but just to avoid Download time (JavaScript alone is 2 MB ) i also want to distribute as desktop client.
what i am looking for are :
Should work in Mac , Linux, and Windows and possibly android
Browser controls are unnecessary (location bar etc)
Should be able to run eval coz qooxdoo use eval selectively which make adobe air unable to work .
I know how to do in Xulrunner but I would prefer to do host it inside google chrome. I also finding a way to bundle xulrunner in portable way (is that already portable?can just download and run directly?)
EDIT: I looked Prism and its promising but is there anyway to bundle Client Side Web Content in a web bundle for Prism ? From its descrpition on Mozilla Wiki , we can't do that.
node-webkit looks like a viable option for packaging the entire application. I haven't used it and have only recently found out about it.
Appcelerator is an option, however there are some restrictions when using it. Some have successfully used the qx-oo (just the OO layer) with Appcelerator. Search "qooxdoo appcelerator" for more information. There may be issues when using it with the qooxdoo UI layer (which is likely the whole point of your using qooxdoo.
Lastly, one "low tech" option might be to save the web page to your local computer via your web browser and then re-distribute those saved files as the "app." I'd expect lots of problems with this, though. For example, if you're dynamically loading different components in qooxdoo these scripts might not be saved. It's easy enough to try, though.

Desktop application development with Javascript and HTML

I am looking for Titanium Appcelerator alternatives for Desktop application development with HTML and JavaScript. I want to convert a web app to a desktop application. Hence, there will be a lot of server interaction. Appcelerator was a good choice, but it looks like the company is no longer interested in the Desktop SDK. Also, ajax request from Appcelerator does not retain cookies.
I read that Adobe Air can be used for desktop app development, but I don't want to use flash.
How good is XULRunner? Will it allow features like Growl notificaiton and creating tray icons?
Will I be able to develop applications using mostly Javascript and HTML in Qt?
I started looking into Titanium for desktop dev. I liked the concept but not the implementation. I then stumbled upon chromiumembedded and have been mostly very happy with it. It's basically a web browser control based on chromium.
http://code.google.com/p/chromiumembedded/
It's written in C++ so you can do all the low level OS stuff you want(Growl, tray icons, local file access, com ports, etc) in your container app, and then all the application logic and gui in html/javascript. It allows you to intercept any http request to either serve local resources or perform some custom action. For example, a request to http://localapp.com/SetTrayIconState?state=active could be intercepted by the container and then call the C++ function to update the tray icon.
It also allows you to create functions that can be called directly from javascript.
My biggest challenge has been debuging. It's very difficult to debug javascript directly in CEF. There's no support for anything like Firebug that I am aware of.
Appjs (appjs.org) looks very promising.
You could also check Bowline which is another alternative: http://bowlineapp.com/.
Although it's not officially intended for general-purpose use, a number of people have had success using brackets-shell for HTML/JS desktop apps. It embeds Chromium (CEF) and adds APIs for menu bar management and file IO. It also embeds an instance of Node.js so you get access to all its APIs for launching processes, etc. It's MIT-licensed and available for Mac & Win, with a Linux version currently making rapid progress.
As I mentioned, it's not officially a general-purpose app shell, but someone wrote a detailed blog post about how to customize brackets-shell for your own uses.
I notice that the other answer about Titanum says CEF is hard to debug. I'm not sure if that's true in Titanium, but in brackets-shell it's easy to debug JS – you just open http://localhost:9234/ to load a full instance of the Chrome Developer Tools (including breakpoints, profiling, etc.).
TideSDK is a continuation of the old Titanium desktop http://www.tidesdk.org/

Categories

Resources