Next-generation platformDeprecated

Application-side changes

Use this procedure to perform the application-side changes required to create a hybrid application using Apache Cordova.

Procedure

  1. Copy the contents of <cordova_project folder>/platforms/<platform>/platform_www to the <Runtime>/extn/cordova/<UserAgentName> folder.
    Notes:
    • UserAgentName is the value set for the AppendUserAgent preference in config.xml.
    • If you are creating the project for multiple platforms, repeat the step for each platform.
  2. Add the following entries in customer_overrides.properties for loading the cordova plug-in files.

    yfs.isf.cordova.supportCordovaApp =Y

    yfs.isf.cordova.useragent.<UserAgentName>=../extn/cordova/<UserAgentName>/cordova.js

    For example:
    yfs.isf.cordova.useragent.cordova-android=../extn/cordova/cordova-android/cordova.js
    yfs.isf.cordova.useragent.cordova_ios=../extn/cordova/cordova-ios/cordova.js
    Note: 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
  3. Add cordova-<feature/plugin>.config.js to store extensions. This config file should implement CordovaPluginInitialization interface and return a function which initializes the cordova plug-in.
    For example:store-cordova-barcode.config.js
    import { 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);
             }
    
    
                };
    
    
          }
    
    
    }
  4. Register the plug-in config file in AppShellExtensionModule using registerPluginInitialization method from CordovaService.
    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);
      }
     }
    
  5. Build and deploy the customizations. For more information, see Building and deploying your customizations.