Ionic2, how to import custom plugin (appsee or uxc

2019-05-29 02:07发布

问题:

I am trying to use Appsee or UXcam

I tried import like below, but no luck // import { Appsee } from '@ionic-native/appsee';

Else where i saw that you have to declare the variable in question for typescript to recognize the variable, I did that like below

declare var cordova:any;

// import { Appsee } from '@ionic-native/appsee';

declare var cordova:any;

@Component({
  templateUrl: 'app.html'
})
export class MyApp {

  rootPage:any = LoginPage;       // FOR TESTING

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
    cordova.plugins.Appsee.start("my key");

      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });
  }
}

I've also tried adding public appsee: Appsee to the constructor but still no luck.

Any guidance is appreciated. I'm getting ReferenceError: cordova is not defined.

How do I import a custom plugin, appsee

edit adding suggested code declare var Appsee:any;

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = LoginPage;       // FOR TESTING

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
    Appsee.start("my key");

      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });
  }
}

回答1:

You just need to put it under the imports as shown below.

//your other imports here

declare var Appsee:any;

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;