导入 Cordova 插件
Importing the Cordova plugin
我正在使用 ionic3 中的 phoneRTC 创建实时音频通话应用程序。
我已经使用以下命令添加了 cordova 插件
ionic cordova plugin add cordova-plugin-phonertc --save
这将以下几行添加到我的 package.json
"cordova": {
"plugins": {
"com.dooble.phonertc": {}
}
}
然后是 config.xml
<plugin name="com.dooble.phonertc" spec="~2.0.1" />
现在,我不知道如何在我的 home.ts 文件中使用或导入它。
由于 phonertc
不是本机插件,您必须像这样使用它:
.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
});
}
}
注:
如果上述方法不起作用,您可以尝试另一种方法,该方法已在 this article 中进行了说明。(请参阅标题 Using a Plugin Not Included in Ionic Native
)
我正在使用 ionic3 中的 phoneRTC 创建实时音频通话应用程序。
我已经使用以下命令添加了 cordova 插件
ionic cordova plugin add cordova-plugin-phonertc --save
这将以下几行添加到我的 package.json
"cordova": {
"plugins": {
"com.dooble.phonertc": {}
}
}
然后是 config.xml
<plugin name="com.dooble.phonertc" spec="~2.0.1" />
现在,我不知道如何在我的 home.ts 文件中使用或导入它。
由于 phonertc
不是本机插件,您必须像这样使用它:
.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
});
}
}
注:
如果上述方法不起作用,您可以尝试另一种方法,该方法已在 this article 中进行了说明。(请参阅标题 Using a Plugin Not Included in Ionic Native
)