Mobile Development

From Sinfronteras
Revision as of 23:05, 12 October 2019 by Adelo Vieira (talk | contribs) (Cordova/PhoneGap)
Jump to: navigation, search

Device Considerations


Platform

Will you be developing for multiple platforms?

  • Android
  • iOS
  • Windows 10 Mobile
  • Blackberry 10
  • Firefox OS
  • Sailfish OS
  • Tizen
  • Ubuntu Touch
  • CynaogenOS



Hardware

  • Depending on the device, the specifications of hardware can be very different
  • Some devices may not have certain components
  • Vintage of components, such as processors and busses will make a difference to the chosen route



Language

  • What programming languages are supported natively by the device?
  • What language suits what you want to do best?
  • Do you need a combination of languages for collaborative tasks?



Form factor

  • Most platforms/OSes run on multiple devices, some more than others
  • Can your application be utilised on all form factors regardless of screen/size?



Native vs Hybrid Frameworks


Native Application Frameworks

Native application frameworks allow developers to access the native platform/OS API directly through code and develop their applications directly to the platform standards and practices


  • Pros:
  • Without other intermediate layers, this provides the best application per device in terms of performance
  • There is no third-party dependence on access to updates and bug fixes


  • Cons:
  • As a native application is written and compiled for a specific platform/OS, deployment on another platform typically requires the maintenance of a totally separate project for each of the supported platforms.
  • How the application is distributed can be different for each platform, requiring the maintenance of a separate distribution channel per platform



Hybrid Frameworks

Web-based frameworks are essentially tools/processes/procedures that allow us to write an application as a website rather than using any native code (e.g. PhoneGap/Cordova)


  • Pros:
  • Anyone with basic web-development skills (HTML, CSS, JS) can write a decent application.
  • There are several frameworks to choose from.
  • It is possible to wrap the content in an application or just access it with the built-in browser.
  • Applications can be accessible across multiple platforms.


  • Cons:
  • Going through so many higher-level languages and interpreters makes run-time much slower than a native application
  • Each platform has a unique style and mode of operation. This gets lost in a web-based application or, at least, requires a lot of work to make it seem intuitive for each platform.



Cordova/PhoneGap

https://cordova.apache.org/

https://phonegap.com

Apache Cordova/PhoneGap enables software programmers to build applications for mobile devices using CSS3, HTML5, and JavaScript instead of relying on platform-specific APIs like those in Android, iOS, or Windows Phone. It enables wrapping up of CSS, HTML, and JavaScript code depending upon the platform of the device. It extends the features of HTML and JavaScript to work with the device. The resulting applications are hybrid, meaning that they are neither truly native mobile application (because all layout rendering is done via Web views instead of the platform's native UI framework) nor purely Web-based (because they are not just Web apps, but are packaged as apps for distribution and have access to native device APIs).


Is PhoneGap equal to Cordova? https://www.businessofapps.com/news/apache-cordova-adobe-phonegap-know-real-differences/

PhoneGap is a distribution of Apache Cordova. So Apache Cordova serves as the engine to power PhoneGap just like WebKit is an engine that powers Chrome and Safari (iOS browser). Nonetheless, as an app developer or as an organization, you don't have to worry about the differences between these two. The story is like this:

  • PhoneGap was previously a product of Adobe.
  • To keep it open-source always and follow standards, PhoneGap codebase was handed over to Apache.
  • At Apache, it got a name change as Cordova.
  • And now it’s better known as Apache Cordova.

The most important to understand here is that PhoneGap is powered by apache Cordova. PhoneGap is Cordova plus some extra Adobe stuff. If you are developing a hybrid mobile app, you can either create it using proper Cordova or choose Adobe's ecosystem for using PhoneGap distribution of Cordova.

The open-source Cordova/PhoneGap will be always free and delivered by Apache. Over time, Adobe may add values to this (current) codebase that consists of other Adobe services and that will be named as PhoneGap, which will be chargeable.



Installing Cordova

https://cordova.apache.org/docs/en/latest/guide/cli/


The Cordova command-line tool is distributed as an npm package.


  • Install Cordova with NPM:
sudo npm install -g cordova

The -g flag above tells npm to install cordova globally. Otherwise it will be installed in the node_modules subdirectory of the current working directory.


  • Check Cordova Version:
cordova --version


If you don't already have one. Following installation, you should be able to invoke git on your command line. The CLI uses it to download assets when they are referenced using a url to a git repo.



Using Cordova

https://tecadmin.net/install-cordova-on-ubuntu/ :



Create the Cordova application environment - Project folder

Use the Cordova command to create your Application. Execute the below command to create an Cordova application environment with name myapp:

cordova create myapp


Now add the required platform in your application. This will create required files for the corresponding platform under the platforms/android and platforms/ios directories (may be necessary to use sudo):

cd myapp
cordova platform add ios
cordova platform add android


Use below command to list the installed and available platforms for Cordova application:

cordova platform -ls


If you accidentally added any platform which you no longer needs, just remove that using commands like below:

cordova platform remove ios
cordova platform remove android



Build the Cordova Application

Before building a Cordova application, make sure that the system fulfills all the requirements for your build environment:

cordova requirements


On all requirements completed successfully run the build command to build your application:

cordova build              ## Build all added platforms 
cordova build android      ## Build for specific platform