So, you've done setting up push notifications for Android via Unity. And it works great! Except, it's showing the default square icon as its notification icon.
So, how do you change it to something sweet that you have made yourself? Because there does not seem to be any built-in options inside Unity.
You can, by making your own Android Plugin folder, putting your resource icon there and create a child Android manifest file which tells the Android build to use the icon as the notification icon.
1. Create an Android Plugin folder
First, you will need to create a new Android Plugin folder inside /Assets/Plugins/Android.
For example, let's give the name of our 'plugin' MyProjectPlugin. Hence, you'll need to create the folder /Assets/Plugins/Android/MyProjectPlugin . Then inside the folder, create the folder 'res' and insert the drawable folders as per how Android manages its drawable resources.
Simply follow the following screenshot:
2. Set the icons
For the icons, if you do not have an icon ready, you can simply use Android Asset Studio to create one. Here's an example: http://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=clipart&source.clipart=ac_unit&source.space.trim=1&source.space.pad=0&name=ic_stat_icon_default
...simply create, name the icon ic_stat_icon_default , download the icon and copy them into the 'res' folder.
3. Set the Android manifest file and the project.properties file.
To ensure that Unity recognizes this folder as a plugin (and will include the drawables you included inside the Android build), you'll need to add the project.properties file and an Android manifest file.
Create a text file named project.properties with the following content:
...and save it inside /MyProjectPlugin/
Next, create a file named AndroidManifest.xml and fill the content with this:
<?xml version="1.0" encoding="utf-8"?> <!-- A plugin to set the default notification icon --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myawesomeproject.myprojectplugin" android:versionName="1.0" android:versionCode="1"> <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" /> <application> <!-- Set custom default icon. This is used when no icon is set for incoming notification messages. See README(https://goo.gl/l4GJaQ) for more. --> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_stat_icon_default" /> <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming notification message. See README(https://goo.gl/6BKBk7) for more. --> <!-- <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/colorAccent" /> --> </application> </manifest>
Be sure to replace the package name com.myawesomeproject.myprojectplugin and the drawable name ic_stat_icon_default to whatever you want.
4. Build and test push notification
You're done! Now just make an Android build and install the damn thing on your Android. Then test the push notification and see if the icon have been updated to whatever you have set.
We're a lazy bunch so here's a file that already have everything above. You just need to change the icon to whatever you want. Download here: MyProjectPlugin.zip (16 KB)