Ionic Native wrapper for Cordova splash screen plugin providing programmatic control over splash screen display in mobile applications.
npx @tessl/cli install tessl/npm-ionic-native-splash-screen@4.20.0Ionic Native Splash Screen is a TypeScript wrapper for the Cordova splash screen plugin that provides programmatic control over splash screen display in Ionic applications. It offers a simple Angular service-based API with show() and hide() methods for managing splash screen visibility during application lifecycle events.
npm install @ionic-native/splash-screenimport { SplashScreen } from '@ionic-native/splash-screen';For Angular applications, also import from core:
import { IonicNativePlugin } from '@ionic-native/core';import { Component } from '@angular/core';
import { SplashScreen } from '@ionic-native/splash-screen';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html'
})
export class HomePage {
constructor(private splashScreen: SplashScreen) {}
showSplash() {
this.splashScreen.show();
}
hideSplash() {
this.splashScreen.hide();
}
}The Splash Screen plugin follows the Ionic Native architecture pattern:
cordova-plugin-splashscreen@Plugin and @Cordova decorators for plugin metadata and method configurationDisplays the application splash screen programmatically.
/**
* Shows the splashscreen
*/
show(): void;Hides the application splash screen programmatically.
/**
* Hides the splashscreen
*/
hide(): void;/**
* Main service class for controlling splash screen display
* Extends IonicNativePlugin and provides Angular dependency injection
*/
@Injectable()
export class SplashScreen extends IonicNativePlugin {
show(): void;
hide(): void;
}The SplashScreen class inherits utility methods from IonicNativePlugin:
/**
* Static methods available on the SplashScreen class
*/
interface IonicNativePlugin {
/** Returns boolean indicating if the plugin is installed */
static installed(): boolean;
/** Returns the original Cordova plugin object */
static getPlugin(): any;
/** Checks if the plugin is available and installed */
static checkInstall(): boolean;
/** Returns the plugin's name */
static getPluginName(): string;
/** Returns the plugin's reference path */
static getPluginRef(): string;
/** Returns the plugin's install name */
static getPluginInstallName(): string;
/** Returns the plugin's repository URL */
static getPluginRepo(): string;
/** Returns array of supported platforms */
static getSupportedPlatforms(): string[];
}The plugin is configured with the following metadata:
interface PluginConfig {
pluginName: 'SplashScreen';
plugin: 'cordova-plugin-splashscreen';
pluginRef: 'navigator.splashscreen';
repo: 'https://github.com/apache/cordova-plugin-splashscreen';
platforms: ['Amazon Fire OS', 'Android', 'iOS', 'Windows'];
}interface CordovaOptions {
/** Set to true if the wrapped method is a sync function */
sync?: boolean;
/** Set to true to return an observable */
observable?: boolean;
/** Callback order, set to reverse if success/error callbacks are first 2 arguments */
callbackOrder?: 'reverse';
/** Callback style */
callbackStyle?: 'node' | 'object';
/** Set custom index for success callback function */
successIndex?: number;
/** Set custom index for error callback function */
errorIndex?: number;
/** Success function property name for object callback style */
successName?: string;
/** Error function property name for object callback style */
errorName?: string;
/** Supported platforms for this method */
platforms?: string[];
}Install the Ionic Native packages:
npm install @ionic-native/core @ionic-native/splash-screenInstall the Cordova plugin:
ionic cordova plugin add cordova-plugin-splashscreenAdd to Angular module providers:
import { SplashScreen } from '@ionic-native/splash-screen';
@NgModule({
providers: [
SplashScreen,
// other providers...
]
})
export class AppModule { }Inject into components:
constructor(private splashScreen: SplashScreen) { }The splash screen methods are synchronous and do not throw exceptions. If the underlying Cordova plugin is not available, the methods will fail silently. Use the inherited installed() method to check plugin availability:
if (SplashScreen.installed()) {
this.splashScreen.show();
} else {
console.log('Splash screen plugin not available');
}