Cordova is an open source framework for quickly building cross-platform mobile apps using HTML5, JavaScript, CSS etc.
Cordova is an application container technology that allows you to create natively-installed applications for mobile devices using HTML, CSS and JavaScript. The core engine for Cordova is also 100% open source, under the Apache Cordova project.
The UI layer of a Cordova application is a web browser view that takes up 100% of the device width and 100% of the device height.
Cordova provides an application programming interface (API) that enables you to access native operating system functionality using JavaScript. You build your application logic using JavaScript and the PhoneGap API handles communication with the native operating system.
Cordova currently supports all major mobile platforms:
- iOS
- Android
- Windows Phone 8
In this article we will see the step by step setup process for developing Apache/Cordova cross platform mobile application development in Universal Windows Platform.
You can download Visual Studio 2017 from here.
At the time of installation, select Apache Cordova cross platform mobile app development tool to install.
Figure 1: VS 2017 installation for Apache Cordova
After completing the installation process, please open visual studio 2017.
Figure: 2
Now click on the New Project section from the file menu.
Figure: 3
Now click on the File menu and then click on the New menu and select Project from there. Then you will see the project template menu like the below figure. Then select JavaScript and click on the Apache Cordova Apps section. Then select Blank App (Apache Cordova from the app template section.) Now write a name of the project and then click OK button.
Figure: 4
Now you will see that a new Cordova universal windows app is ready on your visual studio 2017
Figure: 5
Now a new Cordova project will be created and then you will see newly created Cordova files in the solution explorer. Here in the merges folder, you will see different platform related JavaScript libraries. In the dependencies section you will see Cordova client side package manager related files like npm and bower files. If you install any Phonegap plugin, then a new plugin folder will appear and plugin codes will be on that folder. On the res folder you will see resource files like icons for different platforms, android ant property files and platform based screen images. On the www folder we will see our HTML5, CSS and JavaScript files. We will mostly write our codes here. On the config.xml file you can change configuration of your project, add or remove plugins and set names and versions for different platforms.
Figure: 6
Now click on the index.html page. Then you will see below codes for index.html.
- <!DOCTYPE html>
- <html>
- <head>
- <!--
- Customize the content security policy in the meta tag below as needed. Add 'unsafe-inline' to default-src to enable inline JavaScript.
- For details, see http:
- -->
- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
-
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
- <meta name="format-detection" content="telephone=no">
- <meta name="msapplication-tap-highlight" content="no">
- <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
- <link rel="stylesheet" type="text/css" href="css/index.css">
- <title>BlankCordovaApp3</title>
- </head>
- <body>
- <div class="app">
- <h1>Apache Cordova</h1>
- <div id="deviceready" class="blink">
- <p class="event listening">Connecting to Device</p>
- <p class="event received">Device is Ready</p>
- </div>
- </div>
- <script type="text/javascript" src="cordova.js"></script>
- <script type="text/javascript" src="scripts/platformOverrides.js"></script>
- <script type="text/javascript" src="scripts/index.js"></script>
- </body>
- </html>
Listing: 1
In the above code,src=”cordova.js” is referencing updated installed Cordova library and src=”scripts/platformOverrides.js” file is referencing the library platform independence of this application.
Figure:6
From figure 6 you can see supported platforms for Cordova, you can run your app in those platforms which are, Android, iOS< Windows-ARM, Windows-x64, Windows-x86.
Figure: 7
If you want to run your app in iOS platform, then you can see above available options for you to test your app.
Figure: 8
If you want to run your app in Android platform, then you can see above available options for you to test your app.
Figure: 9
Here, to run the app in universal windows platform, I have selected Windows-x64 and Local Machine as the mode.
Your app will build now, it may take some time. After that it will deploy in your local machine and you will see your app like the below screenshot.
Figure: 10