Error "tried calling SplashScreen.hide, but the SplashScreen plugin is not installed"

Hi,
on an Ionic4 app, I have a problem with the splash screen, that doesn’t close.
In debug mode I can see this error:

vendor.js:77445 Native: tried calling SplashScreen.hide, but the SplashScreen plugin is not installed.
pluginWarn @ vendor.js:77445
Install the SplashScreen plugin: 'ionic cordova plugin add cordova-plugin-splashscreen'
pluginWarn @ vendor.js:77457

The strange thing is that the splash screen is installed, and until yesterday the app was working.
What could be the problem according to you?

Thank you very much

claudio

Do you have the project up on GitHub? Or can you replicate this in a demo project? Can’t really tell what the issue is from this.

As usual it was my fault, I had forgotten that in the meantime I had modified this part of the code:

  initializeApp() {
    const context = this;
    context.settings.initAppSettings();
    context.platform.ready().then(() => {
      context.statusBar.styleDefault();
      context.splashScreen.hide();
...
}

Removing the context.platform.ready() condition, so probably the tried to close the splash screen to soon,

Now it works.

Claudio

Why do you have const context = this? Since things are classes this should scope correctly

I use It sometimes because, when I use the Chrome debugger, into the Promises, “this” isn’t the object I expect it to be.

I know this is off-topic, but just to answer to your question.
If I have this code:

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html'
})
export class AppComponent {

	...
	myTestClassVariable: number;

  constructor(
    private platform: Platform,
	.....
  ) {
    this.initializeApp();
    this.myTestClassVariable = 5;
  }

  initializeApp() {
    const context = this;
    context.settings.initAppSettings();
    context.platform.ready().then(() => {
      console.log(this.myTestClassVariable);
      debugger;
	  ...
	  }
  }
}

When Chrome stops at the breakpoint I have this situation:

ScreenHunter_397 Mar. 28 00.19 !

and:

ScreenHunter_398 Mar. 28 00.21 !

FWIW, I just tried this with the following:

export class HomePage {
  fruit = "apple";

  constructor() {
    Promise.resolve().then(() => {
      console.log(this.fruit);
      debugger;
    });
  }
}

When the debugger statement fires, this resolves as expected to the HomePage object. I wonder what’s different in our situations. My Chrome is 80.0.3987.132.

With this code:

  public myTestVariable1 = 10;
  public myTestVariable2 = 20;

  constructor(private formBuilder: FormBuilder,
              private navCtrl: NavController,
       ...) {
    Promise.resolve().then(() => {
      console.log(this.myTestVariable1);
      debugger;
      console.log(this.myTestVariable2);
    });

The number printed is the right one, when the browser executes the code, but “this” is undefined when you check its value in the Chrome debugger:

ScreenHunter_404 Mar. 28 17.11
I’m using Chrome 80.0.3987.149.
The second number printed is the right one even if in the debugger “this” is undefined.
So I think that they have a different context.

cld