Socket
Socket
Sign inDemoInstall

@capacitor-community/app-icon

Package Overview
Dependencies
2
Maintainers
43
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @capacitor-community/app-icon

Capacitor community plugin for changing an iOS app icon.


Version published
Weekly downloads
1.8K
increased by35.03%
Maintainers
43
Install size
40.1 kB
Created
Weekly downloads
 

Readme

Source


App Icon

@capacitor-community/app-icon

Capacitor community plugin for managing an app's icon. The main feature being that you can programmatically change the app icon.


Maintainers

MaintainerGitHubSocial
John Borgesjohnborges@johnborges

Before Starting

This plugin only changes the main app icon on the device homescreen. The icon in springboard and in other areas will not change and continue to show the original. (iOS)

Changing the app icon is only allowed when the app is in the foreground (iOS).

Android support is currently in beta. See the android-support branch for more info.

Installation

npm install @capacitor-community/app-icon
npx cap sync

Configuration

The alternate icons need to be included within the app bundle and referenced in the project prior to using this plugin. It is not possible to switch to any icon on the fly without adding it to the project first. Below are the configurations steps for each platform.

Android Configuration

Add Alternate Icons

Add the alternate icons directly to your android project in app/src/main/res.

Setup ApplicationManifest.xml

Each alternate icon is represented by an <activity-alias>. Add all the alternative icons to the ApplicationManifest.xml as child elements under <application>. The name attribute on <activity-alias> must be prefixed with dot . See ApplicationManifest.xml for full example.

<application>
    <!-- ... -->
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTask"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
        android:label="@string/title_activity_main"
        android:theme="@style/AppTheme.NoActionBarLaunch">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <!-- <category android:name="android.intent.category.LAUNCHER" /> -->
        </intent-filter>

    </activity>
    <activity-alias
        android:label="Stencil"
        android:icon="@drawable/stencil"
        android:roundIcon="@drawable/stencil"
        android:name=".stencil"
        android:enabled="true"
        android:exported="true"
        android:targetActivity=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity-alias>
  
  <!-- additional <activity-alias> -->

<application>

iOS Configuration

Taken from https://www.youtube.com/watch?v=AT89ofYpWTU

Create the alternate icons in assets catalog

In XCode go to Assets and create the App Icons.
Then fill with images 1024x1024px

XCode Assets Alternate Icons

The name of the asset should correspond to the name used in the code

Change build settings

  1. Visit Build Settings
  2. Search For App icon,
  3. Select "yes" for Include All App Icon Assets
  4. Include a list (in Alternate App Icon Sets) with precise names of the app icons in the Assets Catalogue.

Build Settings XCode

Usage

import { AppIcon } from '@capacitor-community/app-icon';

const changeIcon = async (iconName) => {
  await AppIcon.change({name: iconName, suppressNotification: true});
}

const getName = async () => {
  const { value } = await AppIcon.getName();
  console.log(value);
}

const resetIcon = async () => {
  const disable: string[] = ['stencil']; // all added aliaces names 
  await AppIcon.reset({ suppressNotification: true, disable });
}

API

isSupported()

isSupported() => Promise<{ value: boolean; }>

Checks if changing the app icon is supported. (iOS only)

Returns: Promise<{ value: boolean; }>

Since: 1.0.0


getName()

getName() => Promise<{ value: string | null; }>

Gets the name of currently set alternate icon. If original icon is set, returns null.

Returns: Promise<{ value: string | null; }>

Since: 1.0.0


change(...)

change(options: IconOptions) => Promise<void>

Changes app icon to specified alternate.

ParamType
optionsIconOptions

Since: 1.0.0


reset(...)

reset(options: ResetOptions) => Promise<void>

Reverts app icon to original.

ParamType
optionsResetOptions

Since: 1.0.0


Interfaces

IconOptions
PropTypeDescriptionSince
namestringName of alternate icon to set
disablestring[]Name of icons to disable. This is not used for iOS, but required for Android.3.1.0
suppressNotificationbooleanFlag controlling the in app notification which shows after icon is changed. (iOS)
ResetOptions
PropTypeDescriptionSince
suppressNotificationbooleanFlag controlling the in app notification which shows after icon is changed (iOS).
disablestring[]Name of icons to disable. This is not used for iOS, but required for Android.3.1.1

Contributors ✨

Thanks goes to these wonderful people (emoji key):

John Borges
John Borges

💻
Simon Grimm
Simon Grimm

💻
Christian von Rohr
Christian von Rohr

💻
QliQ.dev
QliQ.dev

💻
Hadouin
Hadouin

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

FAQs

Last updated on 21 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc