Blank screen on Android/iOS after capacitor build when calling SplashScreen in ngOnInit
27.5K reputation · 16 May 2023, 18:40 UTC
The goal is to ensure that Capacitor plugin invocations (e.g., SplashScreen, StatusBar, Network) execute successfully both during local development with ionic serve and in production builds generated by ionic capacitor build android or ios.
When such plugins are called in the root component’s ngOnInit or constructor, the calls succeed in the browser because the web runtime mocks the plugin layer, but they fail in native builds where the Capacitor platform is not yet initialized, often resulting in an undefined plugin object, a blank screen, or an uncaught promise rejection.
It remains unclear where plugin initialization should be placed for root components versus lazy‑loaded modules, whether relying on the @capacitor/app ready event is sufficient for all plugins or if the Ionic Angular Platform service should be preferred, and how to verify plugin readiness without introducing runtime errors in either environment.
Where should plugin initialization be located for root components versus lazy‑loaded modules to guarantee the Capacitor platform is ready?
Is the @capacitor/app ready event adequate for all plugins, or should the Ionic Angular Platform service be used instead?
How can plugin readiness be verified safely in both web and native contexts?