rolinger
rolinger

Reputation: 3066

Setting push notification icon for various Android OS versions

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:

  1. If Android 5 and above are only transparent push notification icons - then how are those two test phones showing the real colored icon?

  2. 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?

  3. 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

  4. 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.

Upvotes: 1

Views: 2626

Answers (1)

andreszs
andreszs

Reputation: 2956

  1. 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)

  2. 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.

  3. 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.

  4. 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.

Upvotes: 4

Related Questions