Built an iOS App Using Cordova
Hybrid  applications are web applications (or web pages) in the native browser, such as
UIWebView in iOS and WebView in Android (not Safari or Chrome). Hybrid Mobile
Applications are Commonly Developed using CSS, HTML & Javascript.
Apache Cordova makes it much more easier, it enables  wrapping  up of CSS, HTML, and
JavaScript code depending upon the platform of the device.
Important Aspects of Apache Cordova:
Single Code Base - Using Cordova Framework, developer can built single mobile app by
targeting multiple platforms.
WebView - User Interface (UI) of Cordova Application uses webview. WebView is being
used in native platforms, Cordova Libraries interact with native framework.
Plug-in - Using Cordova Framework developers can link Javascript code with native code
through robust plug-ins. Developers have an option to choose readymade plug-ins according to
their requirements. Each and every plug-in mapped to Config.xml
Command Line Interface - Developers can use command line interface (CLI) to speed up
mobile app for creating & deploying various platforms. For each targeted platform they must
install SDK before using CLI.
Installing the Cordova CLI (iOS):
Download & Install Node.js, Invoke node & npm in command line. Cordova automatically
downloads npm utility. Open Terminal and type
$ sudo npm install -g cordova
Create the App:
Go to directory where you need to maintain source code & create project
$ cordova create hello com.example.hello HelloWorld
Add Platforms:
Run all sequence of commands inside project directory
$ cd hello
Add platform you want to target your app, for iOS
$ cordova platform add ios
Open project in Xcode
• Navigate to project directory, under platforms there will be ios. Because we added only ios
platform. For android
$ cordova platform add android
• In iOS there will be an Xcode project, open project HelloWorld.xcworkspace. Javascript
code need to be added in WWW folder (WWW/js)
• Images are need to be updated in www folder (WWW/img)
• Project Configurations need to be updated in Config.xml
To call Javascript Function
• Include CDVCommandDelegate in MainViewController.m to use delegate methods & to call
javascript function.
[self.commandDelegate evalJs:@“functionname()”];
Calls Javascript Function, to identify whether function called or not can checked using
console.log() //eg: console.log(“writesomething”)
written in Javascript Function.
Some of Basic Plug-ins
Universal Links:
This plug-in used to open application from browser when user click on the link.
$ cordova plugin add cordova-universal-links-plugin
Facebook Plug-in:
This plug-in uses latest Facebook SDK. Cordova application use native facebook app to
perform single sign in, share app, invite friends etc. If user don’t have facebook app it uses
standard based authentication.
$ cordova  plugin add  cordova-plugin-facebook4 --save --variable APP_ID="Appid" --
variable APP_NAME=“Appname"
Remote Injection Plug-in:
This plug-in Injects cordova and JS into the webview for any remotely browsed page.
Allow to access cordova object and its plug-ins.
$ cordova plugin add cordova-plugin-remote-injection
social sharing Plug-in:
Share text, link, images or other files like pdf, ics. sharing directly to Twitter,
Facebook or other apps.
$ cordova plugin add cordova-plugin-x-socialsharing
By
Ranjith R
iOS Developer

iOS App Using cordova

  • 1.
    Built an iOSApp Using Cordova Hybrid  applications are web applications (or web pages) in the native browser, such as UIWebView in iOS and WebView in Android (not Safari or Chrome). Hybrid Mobile Applications are Commonly Developed using CSS, HTML & Javascript. Apache Cordova makes it much more easier, it enables  wrapping  up of CSS, HTML, and JavaScript code depending upon the platform of the device. Important Aspects of Apache Cordova: Single Code Base - Using Cordova Framework, developer can built single mobile app by targeting multiple platforms. WebView - User Interface (UI) of Cordova Application uses webview. WebView is being used in native platforms, Cordova Libraries interact with native framework. Plug-in - Using Cordova Framework developers can link Javascript code with native code through robust plug-ins. Developers have an option to choose readymade plug-ins according to their requirements. Each and every plug-in mapped to Config.xml Command Line Interface - Developers can use command line interface (CLI) to speed up mobile app for creating & deploying various platforms. For each targeted platform they must install SDK before using CLI. Installing the Cordova CLI (iOS): Download & Install Node.js, Invoke node & npm in command line. Cordova automatically downloads npm utility. Open Terminal and type $ sudo npm install -g cordova Create the App: Go to directory where you need to maintain source code & create project $ cordova create hello com.example.hello HelloWorld Add Platforms: Run all sequence of commands inside project directory $ cd hello Add platform you want to target your app, for iOS
  • 2.
    $ cordova platformadd ios Open project in Xcode • Navigate to project directory, under platforms there will be ios. Because we added only ios platform. For android $ cordova platform add android • In iOS there will be an Xcode project, open project HelloWorld.xcworkspace. Javascript code need to be added in WWW folder (WWW/js) • Images are need to be updated in www folder (WWW/img) • Project Configurations need to be updated in Config.xml To call Javascript Function • Include CDVCommandDelegate in MainViewController.m to use delegate methods & to call javascript function. [self.commandDelegate evalJs:@“functionname()”]; Calls Javascript Function, to identify whether function called or not can checked using console.log() //eg: console.log(“writesomething”) written in Javascript Function. Some of Basic Plug-ins Universal Links: This plug-in used to open application from browser when user click on the link. $ cordova plugin add cordova-universal-links-plugin Facebook Plug-in: This plug-in uses latest Facebook SDK. Cordova application use native facebook app to perform single sign in, share app, invite friends etc. If user don’t have facebook app it uses standard based authentication. $ cordova  plugin add  cordova-plugin-facebook4 --save --variable APP_ID="Appid" -- variable APP_NAME=“Appname"
  • 3.
    Remote Injection Plug-in: Thisplug-in Injects cordova and JS into the webview for any remotely browsed page. Allow to access cordova object and its plug-ins. $ cordova plugin add cordova-plugin-remote-injection social sharing Plug-in: Share text, link, images or other files like pdf, ics. sharing directly to Twitter, Facebook or other apps. $ cordova plugin add cordova-plugin-x-socialsharing By Ranjith R iOS Developer