Skip to content
Projekte

outsung/expo-dynamic-app-icon

Auf GitHub ansehen

Über uns

🤖 Programmatically change the app icon in Expo.

Web- und App-Entwicklung

So werden diese Zahlen gemessen

Gemessener Sternzuwachs

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
Verlauf wird gesammelt

Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.

README.md

Original

expo-dynamic-app-icon

Programmatically change the app icon in Expo.

Install

npx expo install expo-dynamic-app-icon

Set icon file

add plugins in app.json

 "plugins": [
      [
        "expo-dynamic-app-icon",
        {
          "red": { // icon name
            "image": "./assets/icon1.png", // icon path
            "prerendered": true // for ios UIPrerenderedIcon option
          },
          "gray": {
            "image": "./assets/icon2.png",
            "prerendered": true
          }
        }
      ]
    ]

Check AndroidManifest (for android)

expo prebuild

check added line 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>
  ...

Create new expo-dev-client

create a new expo-dev-client and begin using expo-dynamic-app-icon

Use setAppIcon

  • if error, return false
  • else, return changed app icon name
import { setAppIcon } from "expo-dynamic-app-icon";

...

setAppIcon("red") // set icon 'assets/icon1.png'

Use getAppIcon

get current app icon name

  • default return is DEFAULT
import { getAppIcon } from "expo-dynamic-app-icon";

...

getAppIcon() // get current icon name 'red'

Buy Me A Coffee

Ähnliche Projekte entdecken

Wird geladen…