Pro plugin does now work


#1

Hi there,

Pro native plugin does not work on new project. I am receiving error:

Source

How to fix error?

Arnoldas


#2

Ionic Pro is a hosted and closed source service, so there is not much we, the community, can help you with, sorry. Check these:

You can - and should - contact support at http://ionicframework.com/support#support


What is your ionic info output?


#3

@shvercas @Sujan12 the getPlugin() method is a static method defined on IonicNativePlugin - the parent class of all the @ionic-native services.

This method is only defined when a plugin is executing on device. Unfortunately this means the Pro plugin can no longer be loaded in browser :confused: I believe this is a bug and am hoping it gets fixed soon!

In the meantime there is a workaround you can use: instead of INJECTING Pro into your class like this:

constructor(private pro: Pro) { ... }

Instead, you can create it later on by doing the following (this is a snippet from my project’s custom utilities class):

  constructor(private platform: Platform) {
    this.refreshAppInfo();
  }

  // Just a 'for example'. Constructors should not be asynchronous so I split this off to a separate method whose return value doesn't matter.
  async refreshAppInfo() {
    await this.platform.ready();

    if (this.platform.is('cordova')) {
      try {
        this.ionicPro = new Pro(); // magic happens here
        this.appInfo = await this.ionicPro.getAppInfo();
        this.deployInfo = await this.ionicPro.deploy.info();

        console.log('Ionic Pro app info: ', this.appInfo, this.deployInfo);
      } catch (ex) {
        alert('Getting app info exception: ' + JSON.stringify(ex));
      }
    }
  }

This means that the Pro object (and thus exception you are seeing) won’t even get instantiated unless you’re on a device. Thankfully the Pro object uses a simple constructor which allows this to work - some plugins require the Angular dependency injector.


#4

Thank you! Understood.


#5

Only if your report it: https://github.com/ionic-team/cordova-plugin-ionic/issues