2.0.3 β€’ Published 8 months ago

@howincodes/expo-dynamic-app-icon v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

🎨 @howincodes/expo-dynamic-app-icon

Easily change your app icon dynamically in Expo SDK 52!

πŸš€ What's New in v2:

✨ Android icon change without app restart!
✨ Seamless icon updates while the app stays running
✨ Improved stability and performance

🎁 Features:

βœ… Reset icon to default
βœ… Support for round icons
βœ… Different icons for iOS and Android
βœ… Dynamic icon variants for iOS (light, dark, tinted)
βœ… iOS icon update with or without alert popup
βœ… Simple API to get and set the app icon

DemoπŸš€

dynamic-icon-demo-5


πŸ“¦ Installation

npx expo install @howincodes/expo-dynamic-app-icon

πŸ”§ Setup

Add the plugin to your app.json:

"plugins": [
  [
    "@howincodes/expo-dynamic-app-icon",
    {
      "red": {
        "ios": "./assets/ios_icon1.png",
        "android": "./assets/android_icon1.png"
      },
      "gray": {
        "android": "./assets/icon2.png"
      },
      "dynamic": {
        "ios": {
          "light": "./assets/ios_icon_light.png",
          "dark": "./assets/ios_icon_dark.png",
          "tinted": "./assets/ios_icon_tinted.png"
        }
      }
    }
  ]
]

πŸ“œ Android Setup

Run the following command:

expo prebuild

Then, check if the following lines have been added to AndroidManifest.xml:

<activity-alias
  android:name="expo.modules.dynamicappicon.example.MainActivityred"
  android:enabled="false"
  android:exported="true"
  android:icon="@mipmap/red"
  android:targetActivity=".MainActivity">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
  </intent-filter>
</activity-alias>

<activity-alias
  android:name="expo.modules.dynamicappicon.example.MainActivitygray"
  android:enabled="false"
  android:exported="true"
  android:icon="@mipmap/gray"
  android:targetActivity=".MainActivity">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
  </intent-filter>
</activity-alias>

πŸš€ Usage

Set App Icon

import { setAppIcon } from "@howincodes/expo-dynamic-app-icon";

/**
 * Change app icon to 'red'
 */
setAppIcon("red");

/**
 * Reset to default icon
 */
setAppIcon(null);

βœ… Available Parameters:

setAppIcon(
  name: IconName | null,
  isInBackground?: boolean
)
ParameterTypeDefaultDescription
nameIconName \| nullnullThe icon name to switch to. Pass null to reset to the default icon.
isInBackgroundbooleantrue- true: Icon changes silently in the background (no alert on iOS).- false: Immediate change, with system alert on iOS.

βœ… Returns:

  • "DEFAULT" if reset to the original icon.
  • The new icon name on success.
  • false if an error occurs.

Get Current Icon

import { getAppIcon } from "@howincodes/expo-dynamic-app-icon";

// Get the current app icon name
const icon = getAppIcon();
console.log(icon); // "red" (or "DEFAULT" if not changed)

⚠️ Notes:

  • Android limitations:
    Android does not support icon changes while the app is running in the foreground.
    To work around this, the icon is changed when the app enters the Pause state (background).

  • ⚠️ Pause state can also trigger during events like permission dialogs.
    To avoid unwanted icon changes, a 5-second delay is added to ensure the app is truly in the background.

  • To disable the delay and apply the icon change immediately (with the risk of it running during permission dialogs or other pause events), set:

    setAppIcon("red", false);
    • On iOS, isInBackground: false triggers the system alert immediately.
    • On Android, it applies the icon change right away without waiting.

β˜• Support the Original Author

A huge shoutout to outsung for the original package! πŸŽ‰

If you find this useful, consider buying him a coffee:


🌐 About Us

This package is maintained by HowinCloud – delivering powerful cloud-based solutions for modern app development.

πŸ”₯ Enjoy building dynamic and customizable apps with Expo! πŸš€

2.0.3

8 months ago

2.0.2

8 months ago

2.0.1

8 months ago

2.0.0

8 months ago

1.6.8

8 months ago

1.6.7

8 months ago

1.6.6

8 months ago

1.6.5

8 months ago

1.6.4

8 months ago

1.6.3

8 months ago

1.6.2

8 months ago

1.6.0

8 months ago