How use Cordova in Cordova Webview?

Hello

I need your help for my project.

  1. I installed the plugin: Ionic Webview https://ionicframework.com/docs/native/ionic-webview
    Documentation is here: https://github.com/ionic-team/cordova-plugin-ionic-webview

  2. Dynamically, I created an HTML page in this directory: this.file.dataDirectory

  3. I try to load this page on the webview like this:

IMPORT

import {WebView} from '@ionic-native/ionic-webview/ngx';

CONSTRUCTOR

constructor(public webview: WebView) {}

MY CODE

window.location.href = this.webview.convertFileSrc( this.file.dataDirectory + 'jojo/index.html' );

Everything is ok and there aren’t problems. My page jojo/index.html can load.
Now I want to use cordova functions (if possible, I want to use ionic functions)
How can I do that ?

==> Example: when the user click on the #toto button, I want to use the mobile vibration. How can I do that ? (It’s a example of cordova functions)

My config

This is my configuration:

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.4.2
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 11 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/jojo/Library/Android/sdk)
   ios-deploy        : 2.0.0
   NodeJS            : v11.10.0 (/usr/local/bin/node)
   npm               : 6.9.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001

Thank you so much for your help.

1 Like