Search code examples
cordova-pluginssplash-screenionic4

Ionic 4 splash screen not hiding in production mode


I have build an app everything is working perfectly. When i run the app through

ionic cordova run android

But which i run the app in production mode splash screen is not hiding. Alert is also not showing up on platform.ready()

ionic cordova run android --prod --release

here is config.xml

<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="SplashScreenDelay" value="3000" />

app.component.ts

export class AppComponent {
  constructor(
    private platform: Platform,
     private splashScreen: SplashScreen,
     private statusBar: StatusBar
   ) {
    this.initializeApp();

  }

  initializeApp() {
    this.platform.ready().then(() => {
      alert('YES');              //this also not showing in production mode
      this.statusBar.styleDefault();
      this.splashScreen.hide();
    });
  }
}

Solution

  • Sorry! I had installed a native plugin cordova-plugin-x-socialsharing and I did not added it to the provider array in app.module.ts.

    After adding it the native plugin to app.module.ts everything was perfect.

    import { SocialSharing } from '@ionic-native/social-sharing/ngx';
    
    @NgModule({
      declarations: [AppComponent],
      entryComponents: [],
      imports: [
        BrowserModule,
        IonicModule.forRoot(),
        AppRoutingModule
      ],
      providers: [               // Add Native plugins in this array
        StatusBar,
        SplashScreen,
        SocialSharing, 
        { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
      ],
      bootstrap: [AppComponent]
    })
    export class AppModule {}