Sid
Sid

Reputation: 146

Importing the Cordova plugin

I am creating a real time audio calling app using phoneRTC in ionic3.

I have added the cordova plugin using following command

ionic cordova plugin add cordova-plugin-phonertc --save

Which adds following lines to my package.json

"cordova": {
        "plugins": {
            "com.dooble.phonertc": {}
        }
    }

and following to config.xml

<plugin name="com.dooble.phonertc" spec="~2.0.1" />

Now, i don't know how to use or import this in my home.ts file.

Upvotes: 3

Views: 6214

Answers (1)

Sampath
Sampath

Reputation: 65920

Since phonertc is not a native plugin you have to use it like this:

.ts

declare var cordova;

@Component({
})
export class Page2 {

  constructor(public platform: Platform) {

  }

  getMyPluginInfo() {

    this.platform.ready().then(() => {//this is very important

      cordova.plugins.yourPlugin.YourPluginMethod();//replace plugin's name with this `yourPlugin` and `YourPluginMethod` with plugin's method which you want

    });
  }
}

Note:

If above method won't work you can try another method which has been explained in this article.(see it under the title Using a Plugin Not Included in Ionic Native)

Upvotes: 3

Related Questions