Hi there! After adding them, I’m triying to use these plugins (iosrtc and phoneRTC) but both need to be used like:
var session = new cordova.plugins.phonertc....
That’s the Ionic 1 way to do it, but what is the workaround with Ionic 2? I’ve been using native plugins which is very easy, just import and use it, but with non native?
Now it’s working, thank you :)!
I changed my config.xml (adding “plugin name=“com.pylonproducts.wifiwizard” source=“npm” spec=”~0.2.11"/>), the Plugin.xml (the target clobers was window.WifiWizard and I put cordova.plugins.WifiWizard) and the package.json (adding “com.pylonproducts.wifiwizard” to “cordovaPlugins”)! Honestly I never imagined that these could be the problems --’, when a plugin is installed these files should be updated accordingly --’
Now I have this code
import { Component } from '@angular/core';
import { NavController, NavParams, Platform, AlertController } from 'ionic-angular';
import { StatusBar } from 'ionic-native';
declare var cordova;
@Component({
templateUrl: 'build/pages/page2/page2.html'
})
export class Page2 {
public result = {};
constructor(public navCtrl: NavController, navParams: NavParams, public platform: Platform, public alertCtrl: AlertController) {
}
success(results) {
return results;
}
err(e) {
return e;
}
getwifiinfo() {
this.platform.ready().then(() => {
cordova.plugins.WifiWizard.getCurrentSSID(this.success, this.err);
StatusBar.styleDefault();
});
}
}
Hi, sorry I forgot to copy what I have added to config.xml! I edited Plugin.xml and package.json! Basically I looked inside every file of my project and looked for any configuration about plugins and added similar configurations for the plugin that I want to use!
I would love for the moderator to step in. I think the topic of cordova plugins not covered by ionic-native is of the paramaunt importance. It must be, IMHO, part of the tutorial.
Hi, sorry but my code is no longer working :/, I don’t know what happened, it just crashed for no reason, I tried to starting all over again, but nothing! I’ve been struggling with this wifiwizard plugin for months without any success Now I’m getting a similar error!
For those that stumble upon this trying to get ‘non native’ Cordova plugins working, here is some advice I found that helped me when trying to get the Scandit barcode scanner working but I think it applies to plugins in general.
Check the plugin.xml file in the root of the plugin’s directory, e.g. /plugins/com.mirasense.scanditsdk.plugin/plugin.xml, here you will find <clobbers> elements which will indicates the namespace for exported modules of the plugin. Looking at these you can work out how to reference the plugin within your app.
For example, the License module of the Scandit plugin has the following namespace: <clobbers target="Scandit.License"/>
I was able to reference and use it in my code by declaring and using it directly, like so: ... import { Platform } from 'ionic-angular'