Skip to content

Instantly share code, notes, and snippets.

@AustineA
Created March 15, 2023 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AustineA/6486a7c54af3c2389ce450c8f291049f to your computer and use it in GitHub Desktop.
Save AustineA/6486a7c54af3c2389ce450c8f291049f to your computer and use it in GitHub Desktop.
Capacitor App Screenshop
  1. Install npm install --save-dev @capacitor/assets

  2. In your app root create assets folder and add the following

assets/
- logo.png
- splash-dark
- splash

Note: Logo size should be 1024 × 1024 and splash size = 2732 × 2732

  1. Run the command below to generate resource for android or iOS. Feel free to change the hex codes to your prefered colors.

npx capacitor-assets generate --android --iconBackgroundColor '#e1ffe2' --iconBackgroundColorDark '#02100d' --splashBackgroundColor '#e1ffe2' --splashBackgroundColorDark '#02100d'

npx capacitor-assets generate --ios --iconBackgroundColor '#ffffff' --iconBackgroundColorDark '#000000' --splashBackgroundColor '#ffffff' --splashBackgroundColorDark '#000000'

  1. In capacitor.config.ts file add the followning
plugins: {
    SplashScreen: {
      launchShowDuration: 3000,
      launchAutoHide: false,
      showSpinner: false,
      splashFullScreen: true,
      splashImmersive: true,
    },
  }
  1. In your app component install and import

import { SplashScreen } from "@capacitor/splash-screen";

If you're using react run this function on component initialization. On angular adapt and run ngOnInit

export const hideSplash = async () => {
  await SplashScreen.hide();
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment