📜 ⬆️ ⬇️

Innovations in Cordova 5.0

On April 21, 2015, the Cordova team (formerly PhoneGap) released version 5.0 of its tools that allow web developers to develop mobile applications for several platforms at once. The new release contains a lot of new improvements for the developer, which will be discussed further.

In addition to correcting errors, the following improvements were made:


Briefly about Cordova


For those who know what Cordova is, you can skip this section and go straight to the description of the innovations.

Cordova is a platform that allows you to develop mobile applications on different platforms by embedding a browser in a mobile application. Thus, your application is, in fact, a mini-browser that displays a single site - your application. All resources can be placed in the distributed package of the application to speed up the download, and you can download from the server if necessary.
')
By default, Cordova provides only the basic browser features that are available on this mobile device, but it allows you to expand the range of functions available in the browser by using plug-ins. Each plugin provides a unified interface that can be used from a browser on different platforms. And if the supported CSS / JS functions in each browser differ from the version of the operating system or platform, then the Cordova functionality tries to provide unified functionality for all supported versions of mobile OS.

Despite the fact that this approach has its limitations in the form of the need to take into account differences in mobile browsers, it still allows you to create high-quality cross-platform applications.

Innovations


Now, actually, about innovations.

WebView plugin support

Previously, when developing using Cordova, developers were limited only by the functionality of the browser that was preinstalled by the OS. In the case of Android, the difference between the browser installed in versions 4.0.3 and 4.4, and now 5.0, is quite significant, both in terms of functionality and in terms of performance. In iOS, the situation with browsers is better, but there were also highly specific behavioral moments for iOS 7.0 and iOS 7.1. All these differences were quite serious problems in the development.

With the advent of the connected WebView, the situation begins to change and the developer has more options to control the final browser in which the application will run.

Android developers can now, for example, unify the browser that will be used in a hybrid application using CrossWalk . For example, using the following commands you can run your application in Chrome version no less than 40 even on Android 4.0.3, thanks to the engineers from Intel for that:

cordova create hello com.example.hello HelloWorld cd hello cordova platform add android cordova plugin add cordova-plugin-crosswalk-webview 

Similarly, for iOS, it is now possible to use WKWebView instead of UIWebView, which will speed up your application and, as a result, reduce the power consumption of your phone.

For other platforms, there is no support for this functionality yet. But at least, if there is such a need, it can be done.

CSP support

Previously, Cordova used its own mechanisms to manage security when performing web requests in hybrid applications. If earlier you had to rely on proprietary mechanisms for Cordova to control HTTP requests being executed, now you can use Content Security Policy (CSP) for these purposes.

Saving used platforms and plugins in project configuration

Previously, to ensure consistency in joint development of applications, or, for example, when developing on different computers, it was necessary in case of updating the Cordova platform either to remember to make updates on each computer, or to store all platform code in the version control system.

Now the use of the --save parameter allows you not to store the code of the Cordova platform in the version control system. For example:

 cordova platform add android --save cordova plugin add cordova-plugin-crosswalk-webview --save 

Now, a simple execution on another machine:

 cordova prepare 

Restores the Android platform and installs the cordova-plugin-crosswalk-webview plugin for it. Conveniently enough, as for me.

Using NPM to store plugins

Earlier, Cordova maintained its own plugin repository, but with the new release all plugins will have to move to the NPM repository. Now you can search for plugins for Cordova using:

 npm search cordova 

For those who are already working, it is not a matter of principle whether to use the Cordova toolkit, but for those who are just starting to work with Cordova with one command-line utility that needs to be remembered, it will be less. Also, with the advent of closed NPM repositories, you can create your own closed plug-in repositories for Cordova.

Also in connection with this transition, the format of identifiers has changed from org.apache.cordova.device to cordova-plugin-device . Pay attention to this when you read articles on the Internet.

Russian documentation

Also with the advent of version 5.0 appeared Russian documentation . Some of the documentation was translated by me personally, and some was translated using Microsoft Bing, so in some places the translation leaves much to be desired. Despite the fact that the quality of translation from my point leaves much to be desired, from my experience with students it’s better than nothing. I will be grateful for any help with proofreading documentation, even if it is just an indication of those sections that contain automatic translation.

If you have any comments on the work of the latest versions of Cordova, you can write a ticket to JIRA . Those who wish to help with the transfer can register at CrowdIn and help with the translation .

Source: https://habr.com/ru/post/258915/


All Articles