White notification icon - Android 5.0 Lollipop

Hello,
when android:targetSdkVersion is set to higher version than 20,a white box notification icon is displayed in the status bar, instead of the real colored app icon.
Android 5.0 allows only white notification icons in the status bar, according to this:

http://www.reddit.com/r/androiddev/comments/2nz0bt/my_app_notification_has_weird_icon_on_android/

It is possible to set the notification icon in Unity editor somehow? What if we want to use white notification icon for SdkVersion > 20 and another colored notification icon for SdkVersion <= 20?

Thank you for help

//add this line to your android manifest file : i have tested this !!

We’re using a plugin called ELAN. It lets you use an icon different from the app icon which will be used for the notification.

Here’s the plugin:

The trick is to use this to generate your notification icon:
http://romannurik.github.io/AndroidAssetStudio/icons-notification.html

The drawable folders should be inside this folder: (Assets/Plugins/Android/res/)

Basically you need to setSmallIcon of notification builder to the required bitmap.

Just to let you know,
We recently released Cross Platform Native Plugins

This handles coloured and white icons according to the target platform.

If you can let me know which plugin you are using probably I can guide you better.

I haven’t tested it myself but I heard if you set the targetSdk < lollipop then it’ll work:

  <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />

Hi @Klvana,

  • What if we want to use white notification icon for SdkVersion > 20 and another colored notification icon for SdkVersion <= 20?

This is gracefully solved in our plugin UTNotifications. It provides you two options: enabling Android 4.4 Compatibility Mode (which sets targetSdkVersion to 19) or set separate notification icons for Android 5.0+ and lesser versions of Android. It also contains solutions for other Android (and not only) related issues, f.e. restores scheduled notifications after a device reboot, which is not supported by Android directly.

Post android Lollipop release android has changed the guidelines for displaying notification icons in the Notification bar.
The official documentation says "Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray.”
Now what that means in lay man terms is “Convert all parts of the image that you don’t want to show to transparent pixels. All colors and non transparent pixels are displayed in white”

You can see how to do this in detail with screenshots here

Hope that helps

This worked for me:

So you should be able to add your
icon(s) to
Assets/Plugins/Android/res/drawable/
and reference it name

Then, in the notification json, specify your icon. For example:

"notification": {
        "title": "Title",
        "body" : "First Notification",
        "text" : "Text",
        "icon" : "MyIcon"
    }

Note: I used one of these icons.

How I solved it - Open an image editing software (Photoshop) and erase the things that you don’t want in the icon ( this means the background , logos and other unwanted things). The reason is, small icon of android notifications in the mobile notification settings of Unity can only be shown by using alpha channels. further more, the parts of the image or texture which aren’t transparent will be seen and the parts which are transparent wont be seen. So, you might understand that this will be a black&white icon. When you are editing in the image editing software, leave everything that you need to be scene, their color doesn’t matter cuz at the end they will be just white.

If you want a background, try changing the alpha values of the background and the icon( the particular shape which is considered as the icon , ex - A sword as the icon and a background for it)
if you make the background’s alpha values less, it will become a bit transparent than the icon(sword in my example), if you do the opposite, let’s say you deceased the icon’s alpha value, and increased the background, the opposite would happen. [ I didn’t practically check this but according to my knowledge this should work)