Android Lolipop Nexus push notifications plugin icon is white

The Push Notification plugin of cordova presents my icon in white.

I’ve read the following answer:

So how can I create a custom white icon only for Lolipop?

Not sure if you still need help with this, but this is what I did to fix the issue of the icons not displaying on Android .

  1. Install this plugin: https://github.com/phonegap/phonegap-plugin-push

  2. Generate your icons using this website: https://romannurik.github.io/AndroidAssetStudio/icons-notification.html

  3. Download the icons and place them in each appropriate dir in /platforms/android/res . You’ll notice the package from the icon generator has a folder for each sized icon. Place the correct sized icon into each dir. If a dir doesn’t exist, just copy the entire thing over.

Then update the options in the plugin to tell it to use the icon. FYI, you can only use lowercase, otherwise the compiler won’t build.

So in the example below all of my png’s were named notif.png. So the option I set was “icon”: “notif”

image

3 Likes

Hi, how did you get that plugin to work with Ionic?

@diegoserranoa Do you have a specific question or issue your running into? Cause for the most part it just works. Sometimes the plugins have issues with them being added, usually removing and re-adding the platform works or a ‘ionic state reset’ fixes it.

Did you get it working?

Try set this to your config.xml:

<preference name="android-targetSdkVersion" value="20"/> //anything less than 21

7 Likes

Same problem …

did you got it to work?

Yes, for some reason the Android Lolipop Nexus present the push notification icon as white. All colors transform to White.
So, we customized the icon so that it will appear good after the transformation to white. (transparent to present a blank space).

Solved it

            var androidConfig = {
               'senderID'   : _senderid,
               'badge'      : true,
               'sound'      : false,
               'alert'      : true,
               'icon'       : 'icon'
             }; 

added ‘icon’ in the android registration options

I got it to work by generating the icon from push notification icon generator and adding icon:‘res://icon_n’ (icon_n is the name of the icon, omit the extension) to the list of options, make sure you add them in the respective platforms > platform_name > res folders . And i am using the plugin listed here ionic push notification plugin

This was not clear to me at first. The code below is equivalent to calling the init() method. If you’re using Ionic.Push or $ionicPush, you need to pass things through “pluginConfig”

var push = new Ionic.Push({
    "debug": false,
    "onNotification": function(notification) {
        console.log("on notification: " + notification.title);
        return true;
    },
    "onRegister": function(data) {
        console.log(data.token);
        return true;
    },
    "pluginConfig":{
        "android":{
            "icon":"rw_icon_color_trans",
            "iconColor": "red"
        },
        "ios": {
            "badge": true,
            "sound": true,
            "alert":true
        }
    }
});

I was incorrectly trying something like this:

var push = new Ionic.Push({
    "debug": false,
    "onNotification": function(notification) {
        console.log("on notification: " + notification.title);
        return true;
    },
    "onRegister": function(data) {
        console.log(data.token);
        return true;
    },
    "android":{
        "icon":"rw_icon_color_trans",
        "iconColor": "red"
    },
});

Is that working with android-targetSdkVersion >= 21 in your config.xml ?

After adding preference name=“android-targetSdkVersion” value=“20” i can able to see the notification icon in status bar, and notification drawer.

Adding <preference name=“android-targetSdkVersion” value=“20” /> to config.xml worked for me too. Easiest solution so far. Are there any drawbacks for this ?

1 Like

I have already pushed previous versions of my app to the play store when i downgrade my targetSdk=20 it gives me an error tht i cant downgrade my targetSdk version so wht can i do. I tried the push notification icon generator but it is only for APK 11 and it also doesnt work. Still d same.

Any other suggestions?

1 Like

Thanks,
It’s ‘’ really good solutions…

@ceckman, i followed the steps you mentioned. it worked for me . But it converted my icon from colored to white one.