次世代プラットフォーム

アプリケーション側の変更の完了

ApacheCordova を使用してハイブリッド・アプリケーションを作成するために必要なアプリケーション側の変更に関する説明を完了します。

手順

  1. <cordova_project folder>/platforms/<platform>/platform_wwwの内容を' <Runtime>/extensions/isf/webpages/cordova/<UserAgentName>フォルダにコピーする。
    • UserAgentName値は、'config.xmlファイルの'AppendUserAgent属性プリファレンスに設定される。
    • 複数のプラットフォーム用にプロジェクトを作成する場合は、プラットフォームごとに手順を繰り返します。
  2. Cordovaプラグインファイルを読み込むには、'customer_overrides.propertiesファイルに以下のプロパティを追加する。
    • yfs.isf.cordova.supportCordovaApp =Y
    • yfs.isf.cordova.useragent.<UserAgentName>=../extn/cordova/<UserAgentName>/cordova.js
    例えば、'yfs.isf.cordova.useragent.cordova-android=../extn/cordova/cordova-android/cordova.js yfs.isf.cordova.useragent.cordova-ios=../extn/cordova/cordova-ios/cordova.js.

    Cordovaプラグインを別のサーバーでホストしている場合は、適切な URL を提供できます。 例えば、'yfs.isf.cordova.useragent.<UserAgentName> = <baseurl>/<UserAgentName>/cordova.js.

  3. 'cordova-<feature/plugin>.config.tsファイルを追加して、'store-single-spa/extensions/features/override-component/src/app/components/cordova-initialiserに拡張子を保存する。 設定ファイルは 'CordovaPluginInitializationインターフェースを実装し、Cordova プラグインを初期化する関数を返す必要があります。 サンプルの 'barcode-scanner-plugin-config.tsファイルは、'store-single-spa/extensions/features/override-component/src/app/components/cordova-initialiser.
    例えば、'barcode-scanner-plugin-config.tsファイル。
    import { Injectable } from '@angular/core';
    import { CordovaPluginInitialization } from '@sim-core/services/cordova-plugin-config';
    
    @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.
                // fire a event called isf:cordova_barcode_event and pass bardcode data for application
                //window.dispatchEvent(new CustomEvent('isf:cordova_barcode_event',{'detail':{ 'barcode':result.text}}));
                
             }
    
    
                };
    
    
          }
    
    
    }
    config.ts ファイルは、 store-single-spa/extensions/features/override-component/src/app/ フォルダにある app.module.ts ファイルにインポートする必要があります。 プロバイダー配列にエントリーを追加してください。 例:
    import { BarcodeScannerPluginConfig } from './components/cordova-initialiser/barcode-scanner-plugin-config';
    @NgModule({
      declarations: [
        
      ],
      imports: [
       
      ],
      providers: [
      
    BarcodeScannerPluginConfig
      ],
    })
  4. 新規に作成したプラグイン設定ファイルを、'CordovaServiceから'registerPluginInitializationメソッドを使って登録する。 登録は、'store-single-spa/extensions/features/override-component/src/app/components/cordova-initialiserフォルダにある'cordova-initialiser.component.tsファイルの'ngOnInitメソッド内で行う必要がある。
    例:
    CordovaService.registerPluginInitialization(this.barcodeScannerPluginConfig)
    .
    注: cordova-initialiser.component.ts ファイル内の ngOnInit メソッドには、 CordovaService.registerPluginInitialization() メソッドを呼び出すコメントアウトされたコードが含まれています。 ステップ3で作成された設定ファイルをインポートすることで、コードのコメントを解除し、設定ファイルを引数として渡すことができます。
  5. カスタマイズをビルドしてデプロイします。 詳細については、 カスタマイズのビルドとデプロイを参照してください。