To display a custom icon for push notifications on Android, add the icon to an Android library folder in your Unity project and declare it in the AndroidManifest.xml.
Note: For modern Android versions, the status bar icon must be monochrome (white with a transparent background).
Follow these steps:
Prepare your icon: Create your notification icon as a small, white icon on a transparent background (e.g.
notification_icon.png).-
Place the icon in an Android library folder: Unity only compiles Android resources that live inside a
*.androidlibfolder underAssets/Plugins/Android/. The Pushwoosh Unity SDK no longer ships such a folder (since the SDK moved to UPM packages, its Android side is a single.aar), so create your own, for example:Assets/Plugins/Android/my-resources.androidlib/ AndroidManifest.xml project.properties res/drawable/notification_icon.pngThe
AndroidManifest.xmlinside the folder can be minimal (a<manifest>element with your package name), andproject.propertiesshould containandroid.library=true. Without these two files Unity will not treat the folder as an Android library and the drawable will not be packaged. -
Update your main
AndroidManifest.xmlatAssets/Plugins/Android/AndroidManifest.xml. Add the following<meta-data>tag inside the<application>tag:<application ...> <meta-data android:name="com.pushwoosh.notification_icon" android:resource="@drawable/notification_icon" /> </application>You can also set the accent colour with
com.pushwoosh.notification_icon_color. Important: Replace
notification_iconwith the name of your icon file, without the.pngextension. After rebuilding your app, new notifications will display your custom icon.
Comments
0 comments
Please sign in to leave a comment.