Application-side changes
Use this procedure to perform the application-side changes required to create a hybrid application using Apache Cordova.
Procedure
-
Copy the contents of <cordova_project
folder>/platforms/<platform>/platform_www to the
<Runtime>/extn/cordova/<UserAgentName> folder.Notes:
UserAgentNameis the value set for theAppendUserAgentpreference in config.xml.- If you are creating the project for multiple platforms, repeat the step for each platform.
- Add the following entries in customer_overrides.properties for
loading the cordova plug-in files.
yfs.isf.cordova.supportCordovaApp =Yyfs.isf.cordova.useragent.<UserAgentName>=../extn/cordova/<UserAgentName>/cordova.jsFor example:yfs.isf.cordova.useragent.cordova-android=../extn/cordova/cordova-android/cordova.js yfs.isf.cordova.useragent.cordova_ios=../extn/cordova/cordova-ios/cordova.jsNote: If you are hosting the cordova plug-ins on a different server, then you can provide the appropriate URL. For example:yfs.isf.cordova.useragent.<UserAgentName> = <baseurl>/<UserAgentName>/cordova.js - Add
cordova-<feature/plugin>.config.jsto store extensions. This config file should implementCordovaPluginInitializationinterface and return a function which initializes the cordova plug-in.For example:store-cordova-barcode.config.jsimport { Injectable } from '@angular/core'; import { CordovaPluginInitialization } from '@sim-core/services/cordova-plugin-config'; import { BarcodeScannerService } from '@sim-shared/services/barcode-scanner.service'; @Injectable() export class BarcodeScannerPluginConfig implements CordovaPluginInitialization { constructor(private barcodeScannerService: BarcodeScannerService) { } getCordovaPluginInitializationfunc() { return () => { if(<check for plug-in available>){ //Initialize the cordova barcode plug-in if necessary // Configure the barcode plug-in settings to call a method on barcode scan // Refer the plug-in documentation for acessing the barcode data. // call BarcodeScannerService.placeBarcodeToElement method pass bardcode data for application // eg barcodeScannerService.placeBarcodeToElement(data.barcode); } }; } } - Register the plug-in config file in
AppShellExtensionModuleusingregisterPluginInitializationmethod fromCordovaService.For example:import { NgModule } from '@angular/core'; @NgModule({ imports: [], entryComponents: [], declarations: [], exports: [], providers: [ , BarcodeScannerPluginConfig ] }) export class AppShellExtensionModule { constructor( private barcodeScannerPluginConfig: BarcodeScannerPluginConfig ) { CordovaService.registerPluginInitialization(this.barcodeScannerPluginConfig); } } - Build and deploy the customizations. For more information, see Building and deploying your customizations.