I want to convert an Angular JavaScript app into a native Windows application but I don't know how to do it. I heard that electron could be used for this but I don't know how to use electron.
Despite electron there is another solution called nativefier. It is actually quite simple and you don't have to learn a new framework like electron.
As the comments pointed out already, this is not possible.
Why?
JavaScript can't run directly on the machine, neither do HTML and CSS. You need a browser that can understand those languages and turn them into commands your computer can understand.
So your only way to run an Angular App without using chrome or Firefox or whatever browser, is Electron. It's basically a chrome browser plus your custom Angular app packed into an exe. So under the hood, it really just runs your code in a browser environment, but you have more control over it and no address bar etc.
I want to check if a particular app is installed and if it is installed, invoke it.
AFAIK, the way to do it is to check if the custom url scheme of the app is registered and use that url to launch the app.
Is there a way for me to do this in my Cordova app?
To be very specific I want to check if the Google Maps application is installed on iOS and if it is, launch it with its custom url else show the default Apple maps.
This url : https://developers.google.com/maps/documentation/ios/urlscheme : shows how to do it in Objective-C, but how do I do it in Javascript in my Cordova app?
I could not find any plugin to achieve the same. Other questions on SO deal with either doing this from a native app or JS on a regular website (in the browser). The most common work-around is to try launching and use a timeout to see if the app launch failed and still my app is running. This is pretty unclean. Access to the iOS API canOpenURL through JS would be best.
Hints?
Cordova does not ship with this feature. There is a plugin which implements it for iOS, though.
https://github.com/philbot5000/CanOpen
I did not find anything for Android yet, but I do not think this would be hard to do in native Android Code. Even if you are not proficient with Objective-C or Java and never intend to write fully native apps, you should learn some basics if you want to build apps with Cordova.
Small and simple plugins are really easy to do. Read the docs and have a look at the code of some simple plugins to see how it is done. For example the source code of the one above or of the one below is really simple and straightforward to understand:
https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin
I just starting trying out PhoneGap today. I've heard about it before, and I've always thought it translated HTML and Javascript into native code. After trying it, I think the device is executing HTML/Javascript/CSS directly?
I'm confused as what PhoneGap does. Is my device executing raw HTML/Javascript/CSS or is it executing a translated native code?
By the way, I'm developing on Android.
PhoneGap executes your Javascript in the device's native browser.
It does not compile anything, although the browser's JITter probably will.
I'm programming an android app using Applicationcraft, but then I need to create my own plugin for a certain requirement. So I downloaded my app from applicationcraft, then compile it manual using phonegap 1.7.0, but I'm having a problem with my plugin. I have followed every steps in this tutorial, but whenever I use my plugin in a test device I always get this error:
Cannot call method "myfunction" of undefined.
Function: callingFunction
I also consult another question here, but I still having the same problem.
Can anybody tell me what are the possible solutions? Or point me to the right direction (any tutorial for making plugin for PhoneGap 1.7.0). Thanks.
No need, I've already found it here.
I built a PHP / JavaScript website for a customer. Then they asked me to replicate it except as a standalone Mac application. I did this with an app that combined an embedded web server, PHP, and 'WebView' - a Cocoa-ish version of the WebKit web browser that I can embed in a standard app window. This all worked great - I got to reuse 10,000+ lines of PHP/JS code, which saved months off of re-implementing it all again in 'native' code.
Now they want a Windows equivalent. I'm reasonably confident I can get PHP and the web server to work. And I know embedding basic IE functionality is pretty easy.
However...in my Mac setup, WebView (via the windowScriptObject stuff) gave me the ability to call JavaScript methods from C++. For instance, I might call a JavaScript method from C++ to update the screen. Likewise I could set things up so that a JavaScript call in the browser could trigger a C++ method - I used this, for instance, to let a user click 'BROWSE' and pick a file path using a real, standard file browser.
So my question is, is there a Windows-based embedded browser setup that would let me interact with JavaScript in this same way?
(the JavaScript <--> WebKit interface is described in much better detail here: http://lipidity.com/apple/javascript-cocoa-webkit/)
Maybe try using something like Appcelerator Titanium so you'll be ready when your client says they want it to work on Linux, or iPhone, or Android.
Quoting Wikipedia: "Appcelerator Titanium is a platform
for developing mobile and desktop
applications using web technologies.
[...] Support for standards-based web
technologies: HTML, CSS and Javascript
on all platforms along with PHP,
Python and Ruby for desktop platforms.
Integrated support for popular
JavaScript and AJAX Frameworks
including jQuery, YUI, MooTools,
Scriptaculous and others."
Sounds like a perfect tool for the job.
When you embed the Web Browser Control (IE), your application code can simply call execScript (http://msdn.microsoft.com/en-us/library/ms536420(v=vs.85).aspx) on the window object. You can have your script call out to the application by using the window.external object from the script, and by using the ObjectForScripting (or C++ equivalent) from the application.
maybe Qt will be good for your case, also you have QtScript and can inject javascript with evaluateJavaScript
I found a great example on the web for invoking JS in my embedded browser from C...basically using COM-ish methods that let you get a DISPID from a script object, and then using the Invoke() method with that. This works great.
But it turns out I need to also call C++ funcs from my JS code. It appears this is possible, and after hours of messing around I think I almost had it - it's like the above in reverse - you create a COM object, then hook it to the browser's script object - but in the end I could not close the deal - I kept getting "library not registered" errors. Honestly I don't know COM well enough to do this right.
So then I, for the heck of it, tried building my first C# app. In about 20 minutes I had an app running with a browser where I could both invoke JS inside of it and have the browser invoke C# methods. Geesh. I'm a believer in .NET after this experience, and a confirmed non-believer in 90's Microsoft technology.
In the interest of completeness, I'd like to mention my Windows port of WebKit, which includes the various cross-layer features of WebKit on the Mac.
I posted some example code showing how to embed WebKit in a native WinAPI application, complete with JavaScript->C++ and C++->JavaScript examples.
The example is a tiny test case for a much larger application using embedded WebViews for major UI components. I can confirm that what you are doing is not only possible, but a great way to build an application.