Setting push notification icon for various Android OS versions - android

I have 5 test Android phones, each running a different version of OS (5.1, 6.1, 7.1,8 and 9). I get one of two different push notification icons to display - depending on OS version. My app icon is a hexagonal shape.
Samsung Grand Prime, 5.1.1 = real app icon - with colors
Samsung Galaxy S5, 6.0.1 = real app icon - with colors
LG K20 Plus, 7.0 = white hexagonal icon
LG K20 Plus, 8.0 = white hexagonal icon
Google Pixel 3a, 9.0 = white hexagonal icon
I am using cordova-plugin-firebasex (https://github.com/dpa99c/cordova-plugin-firebasex#android-notification-icons) and created all the appropriate notification_icons in the respective drawable folders (mdpi/hdpi/xdpi/xxhdpi/xxxhdpi) - the icons are all mini versions of my real app icon (with colors). I have read in many threads/blogs that above Lollipop (5.0) real app/color Icons are not possible for push notifications. However I have my real app/colored icon displaying as the push notification icon on the Android 5.1.1 and 6.1 test phones.
My questions are as follows:
If Android 5 and above are only transparent push notification icons - then how are those two test phones showing the real colored icon?
Is my understanding of this correct...OR is it possible to get real app icon to appear as push notification icon for Android 7, 8 and 9? If so...how? What else must I do beyond the standard steps defined in the above (also below) Firebasex directions?
If not possible...can anyone answer WHY Google stopped supporting color/real app push notification icons? iOS supports mini app icons as the push notification icon through all rev of their OS. The colored icons really help users know exactly what app just notified them without having to take any further action. A white icon is typically not very recognizable and makes it harder to discern which app just sent the message
If its not possible, then I will need to create transparent icons for 7, 8 & 9 - but how can I have the lower versions still show the real app icons and the uppers versions show the transparent icons? I have one base config.xml - what internal code would I need to add to test for different versions to supply real icon vs transparent icon?
The current config.xml configuration is to define push notification icons is:
<platform name="android">
<resource-file src="res/android/drawable-mdpi/notification_icon.png" target="app/src/main/res/drawable-mdpi/notification_icon.png" />
<resource-file src="res/android/drawable-hdpi/notification_icon.png" target="app/src/main/res/drawable-hdpi/notification_icon.png" />
<resource-file src="res/android/drawable-xhdpi/notification_icon.png" target="app/src/main/res/drawable-xhdpi/notification_icon.png" />
<resource-file src="res/android/drawable-xxhdpi/notification_icon.png" target="app/src/main/res/drawable-xxhdpi/notification_icon.png" />
<resource-file src="res/android/drawable-xxxhdpi/notification_icon.png" target="app/src/main/res/drawable-xxxhdpi/notification_icon.png" />
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="#drawable/notification_icon" />
</config-file>
</platform>
Again, the notification_icon in each of the drawable folders is an appropriate sized mini version of my real app/colored icon.

Because they allowed certain time lapse for developers to update their apps. This time ran out when Android 7 was launched. However, while in those phones you may see the colored icon on the notification bar, you are surely getting a white icon contour only in the detailed notification panel (starting w/Android 5)
You can't. You should use a white icon with PNG transparency together with the color push payload value to get the white icon with your colored background in the detailed notifications panel.
I guess they stopped supporting this because developers tend to create extremely ugly icons, which in small size (18x18 or so) look even worse. In this case it's better to see the icon contour only, also more aesthetically consistent... this is more reasonble than asking developers to design icons with the same style and guidelines. The key here is to have a proper logo, simple but unique, without much detail. Consider the "f" icon from Facebook, or the envelope from Gmail: those icons can always be identified and associated withe the corresponding app even in monochrome palette. If your logo needs a 256x256 resolution to fit all its detail, it's time to call a graphic designer to create a new logo.
The only way to show different icons for different Android versions, is to change the icon payload on the server side before sending the push. You can (and should) save the Android OS version together with your push registration ID for each user. However, I wouldn't recommend you to proceed with this idea of different icons because:
The icon will be wrongly shown in the notification detail starting Android 5
You are generating style inconsistency between users and devices.
Your goal should be the exact opposite; to make sure all users and all devices get to see the same icon in the same style.
Regarding that last point, users in Android 4 won't see the bg color you set in your push, they'll see the PNG transparency icon with the default black background.
I hope my post threw some light to all your push icon doubts, let me know otherwise.

Related

Do new Android versions support colorful notification icons? Since when?

I've been working with Android notifications and the notification icons are behaving differently on my two test devices (one with Android 9 and one with Android 11).
I set the notification icon to be the same as the app's launcher icon, like this:
notificationBuilder.setSmallIcon(R.mipmap.app_icon);
On Android 11, the icons in the notification bar show up exactly like the launcher icon, i.e., colorful (the first two icons are from apps developed by me):
On the other hand, Android 9 applies something like a boolean filter to the icons (here they are round because the launcher app on this phone applies an additional circle filter to the launcher icons):
After some research online, I only found information about how colors are not allowed in notification icons since Lollipop, and how what I am seeing on Android 9 is actually the expected behavior since then.
But what could explain the colorful icons showing up correctly on my Android 11? I assume that this may be a new feature from Android 10 or Android 11, but I couldn't find anything mentioning that in the documentation.
I would like to be sure of something like "colorful notifications icons are supported since SDK 30" (or maybe 29), so that I can set the icons depending on the device versions. More specifically, I would like to use the colorful icons on devices that support that, while using different single-color icons on devices that don't. But unfortunately I don't know for sure which devices/Android versions support it.
Thanks in advance.

forcing square app icon

I will set a square app icon for my Android App made with Android Studio.
I set my own app icon with File -> New -> Vector Asset
This creates a normal and a round app icon.
If I copy and rename (ic_launcher_round.png) the quadratic app icon and install it for example on OnePlus Launcher i get the round icon, too.
My Logo is square, so it is really ugly to see it round.
How I can force a quadratic app icon? Is this possible?
If I set only android:icon="#mipmap/ic_launcher" instead of this and android:roundIcon="#mipmap/ic_launcher_round" in my Manifest.xml nothing change.
Your app's icon will be rounded when a launcher decides to make it rounded.
The "launcher" is just another app, like yours, but it is not your app - it is separated completely from it, and you can't normally influence any process that is separated from your app's process, OS will forbid that.
Only sometimes you would be able to do something like that by utilizing some form of Inter Process Communication (IPC) offered by your OS, assuming of course that the process you want to communicate with is also 'willing to talk' with you [utilizes the same form of IPC to allow other process to change some of its behaviors].
Also the purpose of the Android Studio's wizard you used was to help you generate ready-to-use drawable files and it was just to save your time on making these drawables all by yourself in some image editor.
Any drawable set inside XML manifest file for being your app's round icon will be rounded a t the end and that is no matter how it actually looks. I don't think you can expect any currently available major launcher application to display some apps' icons as round and some as square. It would significantly harm its user experience.
I'm afraid you will have to adapt to this situation and make your square app's logo a little bit smaller and leave some empty space around it to allow end user's launcher app to draw a circle around this logo.
Here you can find official recommendations for designing Android apps' launcher icons: https://material.io/guidelines/style/icons.html#icons-icons-for-android and here you can read about the most current approach in a subject of Android apps' icons: Adaptive ones. Any other type of icon can be treated as 'legacy' and used only for compatability reasons when targeting APIs below 26.
Edit:
In the comments section OP mentioned some apps that do currently have square icons in their newest versions and that turned out to actually be a small UX design flaw of its developers.
Just as an example, I've downloaded Bytecoin app OP mentioned, and this is how it looks like on my phone, Android 7.0:
The red object in the corner has ben cut off. I think we can assume that every other app on the Google Play that displays there with square logo [which looks good in their store pages because Google Play allows square logos] will look bad when installed on phones with modern versions of launchers, especially api >=26.
If your target SDK is 26 and android device version is 8, the app icon will be round.
One of the ways to achieve this is (Not sure if it is the right/best way to do it)
In AndroidManifest.xml I had to set
android:targetSdkVersion=“20”
<uses-sdk android:minSdkVersion=“16" android:targetSdkVersion=“20” />
android:roundIcon=“#mipmap/ic_launcher_round”
<application android:hardwareAccelerated=“true” android:icon=“#mipmap/ic_launcher” android:label=“#string/app_name” android:roundIcon=“#mipmap/ic_launcher_round” android:supportsRtl=“true”>
Ensure the ic_launcher_round images are Squared one.
I used the android studio to generate adaptive and legacy icons…
I deleted the ic_launcher_round images generated by the android studio.
I copied ic_launcher images(Generally the Square icons) to ic_launcher_round.
Now my ic_launcher_round is Squared icons.
(ic_launcher_round.png, ic_launcher.png, icon.png) all of them are the same images
After making this changes, rebuild the app. Now you should see Square icon when you install the app.
Since Android 8.0 (Oreo)
The new way of designing app icons for Android now is described there :
Adaptive icons
Android 8.0 (API level 26) introduces adaptive launcher icons, which can display a variety of shapes across different device models.
When using adaptative icons, launcher icons have 2 layers : foreground and background (see Creating adaptive icons in XML).
The shape (round, square...) can vary depending of the system / launcher settings.
Before Android 8.0
Legacy icons can be generated this way : Create a legacy launcher icon

Notification icons, fully white on some devices, multicolored on others. Why?

My question is not about how to create white icons.
I'm just trying to understand WHEN, exactly, the automatic white filter kicks in.
I've read notification icons, from Lollipop onwards, automatically become white 'silhouettes', so even if you use a multicolored image with setSmallIcon, any non-transparent part of it will turn fully white when displayed in the status bar.
And that's precisely what it actually does on every nexus/pixel emulator I start from android studio. Any android version, among 5, 6, 7, 8, does this.
But I actually didn't find out about this lollipop feature until recently, because all this time, and even now, by loading the exact same app on real devices, I always see the original multicolor image in the status bar. This happens on a samsung s5neo, on a huawei p8lite, and many others.
I asked my users, and apparently some see them white, some see them colored. Some with Oreo see them white, some with Oreo see them colored. It seems it also depends on which specific icons I use, because some users report they see, on the very same device, some of them white and some of them colored.
I use with setSmallIcon either my ic_launcher, so applying it from the resources, or Icon objects created from some Drawables I get from external sources.
And I use pixeled sprites of characters as icons, so when I say colored I don't mean a 'green thing', I mean a really colorful image.
My app has sdk target 27, it also uses some oreo functionalities.
So, what's going on? I read everywhere that it should do the silhouettes on ANY >=lollipop device, but that's obviously not all there is to know about it, and I want to understand better.
How can, for example, my oreo users, see multicolored images, set with setSmallIcon, if I have sdk target 27?
Can someone explain? Thanks!
Create your notification icon using white pixels plus the alpha channel, as documented, and you will get consistent results.
Some device manufacturers tinker with Android. For some, apparently, that tinkering includes supporting non-standard notification icons. You have no good way, ahead of time, of knowing exactly which devices (out of 10,000+ models) will have this behavior.
If a device manufacturer hires you to build an app, or wishes to license an app from you, you might inquire about their notification icon policy and make adjustments to take advantage of whatever they offer.

Instead of the small icon Lollipop displays the launcher icon in the large icon slot

I'm testing on Android 4.4 (on a Motorola Moto E) and Android 5.0 (on a Huawei P8 GRA-L09).
Notifications look the same on both in the status bar. When opened, they look different (I don't have enough reputation to post images):
4.4 displays a larger (scaled?) variant of the small icon.
5.0 displays the launcher icon. It does not even display the small icon as a secondary icon.
I need to display several different notifications and it is not sufficient to see what app they come from.
If I set the large icon (at least in 4.4) the small icon is displayed as a secondary icon, which is useless.
How can I make 5.0 display the small icon as the primary icon?
This must be a bug in the Huawei P8, as the Motorola Moto E does display the icon as expected in Android 5.1 as well. So, to answer the question: There is nothing to do.

Android notifications: have colors in small icon

Since Lollipop, notification small icons are "masks" (only the alpha channel is used).
I can verify this in the project I am working on: previously we had a colorful small icon, and it worked well on 4.4- devices but appeared as a white square on 5.0+ devices. (We updated the icon to fix this).
But now I see apps that manage to have colorful icons on 5.0+ devices!
How do they do it?
I realize I shouldn't even try to do that since the guidelines say the icon should be a white shape, but I am curious and would like to know how it is done.
I suspect this is related to the targetSdk, but didn't find any resources about it.

Categories

Resources