Skip to content

Commit d47a8a9

Browse files
committed
feat(examples): add icon generation script
1 parent 82aedf6 commit d47a8a9

36 files changed

Lines changed: 77 additions & 21 deletions

examples/build.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,24 @@ bunx cap add android
3737
"onesignal-capacitor-plugin": "file:../../onesignal-capacitor-plugin.tgz"
3838
```
3939

40-
App icon generation uses `@capacitor/assets`. Place the OneSignal logo in `assets/icon-only.png`, then:
40+
### App icons
4141

42-
```bash
43-
bunx @capacitor/assets generate --ios --android --iconBackgroundColor '#ffffff' --splashBackgroundColor '#ffffff'
42+
Each demo's `assets/` directory holds the three 1024x1024 source images that [`@capacitor/assets`](https://capacitorjs.com/docs/guides/splash-screens-and-icons) consumes:
43+
44+
```
45+
assets/
46+
├── icon-only.png # OneSignal logo on white
47+
├── icon-foreground.png # OneSignal logo on transparent (Android adaptive foreground)
48+
└── icon-background.png # solid white (Android adaptive background)
4449
```
4550

46-
After generating, remove the adaptive icon files so Android uses the generated PNGs directly (the adaptive icon XMLs reference the default Capacitor foreground and override them):
51+
To (re)generate all native icon assets, run from inside a demo:
4752

4853
```bash
49-
rm -rf android/app/src/main/res/mipmap-anydpi-v26 \
50-
android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml \
51-
android/app/src/main/res/drawable/ic_launcher_background.xml \
52-
android/app/src/main/res/values/ic_launcher_background.xml \
53-
android/app/src/main/res/mipmap-*/ic_launcher_foreground.png
54+
bunx @capacitor/assets generate --ios --android
5455
```
5556

56-
Then verify both platforms picked up the OneSignal logo and not a default Capacitor icon:
57-
58-
- iOS: open `ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png`
59-
- Android: open `android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png`
60-
61-
If either still shows the default Capacitor blue X, re-run the generator. `@capacitor/assets generate` has been observed to silently skip the iOS output on a first run.
57+
That produces the full Android adaptive icon set (foreground/background mipmaps + `mipmap-anydpi-v26/ic_launcher{,_round}.xml`) and the iOS `AppIcon.appiconset`. No additional steps.
6258

6359
### Build & run scripts
6460

@@ -224,7 +220,9 @@ examples/
224220
├── package.json
225221
├── .env.example
226222
├── assets/
227-
│ └── icon-only.png # Source for @capacitor/assets generate
223+
│ ├── icon-only.png # OneSignal logo on white
224+
│ ├── icon-foreground.png # Android adaptive icon foreground (transparent)
225+
│ └── icon-background.png # Android adaptive icon background (solid white)
228226
├── src/
229227
│ ├── main.tsx
230228
│ ├── App.tsx # IonApp + IonReactRouter, StatusBar config
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background>
4+
<inset android:drawable="@mipmap/ic_launcher_background" android:inset="16.7%" />
5+
</background>
6+
<foreground>
7+
<inset android:drawable="@mipmap/ic_launcher_foreground" android:inset="16.7%" />
8+
</foreground>
9+
</adaptive-icon>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background>
4+
<inset android:drawable="@mipmap/ic_launcher_background" android:inset="16.7%" />
5+
</background>
6+
<foreground>
7+
<inset android:drawable="@mipmap/ic_launcher_foreground" android:inset="16.7%" />
8+
</foreground>
9+
</adaptive-icon>
240 Bytes
Loading
4.01 KB
Loading
157 Bytes
Loading
1.72 KB
Loading
176 Bytes
Loading
2.33 KB
Loading
308 Bytes
Loading

0 commit comments

Comments
 (0)