@capacitor-community/app-icon

中文文档
7.0.0发布于 2025/12/25MITTypeScriptESM + CJS零依赖近 30 天下载 2.9万

Capacitor community plugin for changing an iOS app icon.

原始使用文档
文档目录19 节
  1. App Icon
  2. Maintainers
  3. Before Starting
  4. Installation
  5. Configuration
  6. Android Configuration
  7. Add Alternate Icons
  8. Setup ApplicationManifest.xml
  9. iOS Configuration
  10. Create the alternate icons in assets catalog
  11. Change build settings
  12. Usage
  13. API
  14. isSupported()
  15. getName()
  16. change(...)
  17. reset(...)
  18. Interfaces
  19. Contributors ✨


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).

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

📖
Alexander Harding
Alexander Harding

💻

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

版本与发布记录

@capacitor-community/app-icon 共发布 19 个版本,首次发布于 2021/02/02;过去 12 个月发布了 1 个版本。

版本发布日期距今
7.0.0latest2025/12/2510 个月前
6.0.02025/01/231.8 年前
5.0.02024/04/212 年前
4.1.12023/10/083 年前
4.1.02023/05/283 年前
4.1.0-beta.02023/05/173 年前

其他发布通道:capv2-support → 1.1.0。

关于 @capacitor-community/app-icon 的常见问题

@capacitor-community/app-icon 是什么?

Capacitor community plugin for changing an iOS app icon.

如何安装 @capacitor-community/app-icon?

在项目目录运行 npm install @capacitor-community/app-icon,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capacitor-community/app-icon 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capacitor-community/app-icon 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capacitor-community/app-icon 可以商用吗?

@capacitor-community/app-icon 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@capacitor-community/app-icon 的下载量有多少?

根据 npm 官方下载统计,@capacitor-community/app-icon 在 2026/10/09 – 2026/11/07 这 30 天内被下载 29,045 次,日均约 968 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capacitor-community/app-icon 还在维护吗?

最新版本 7.0.0 发布于 2025/12/25(10 个月前);至今共发布 19 个版本,其中过去 12 个月发布了 1 个;首次发布于 2021/02/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。