Ionic2, how to import custom plugin (appsee or uxcam) into Ionic App

此生再无相见时 提交于 2020-01-14 02:12:10

问题


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;


来源:https://stackoverflow.com/questions/47645037/ionic2-how-to-import-custom-plugin-appsee-or-uxcam-into-ionic-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!