1
votes

I am developing a cordova app for Android, iOS and Windows Phone.

I am using the push plugin and the mobile services plugin for cross platform push notifications.

However, This question is related to the push plugin rather than mobile services.

First of all, with iOS, simply including the icon in the res/icons/ios folder and adding "icon": "name" in the init did the job.

For some strange reason with Android, this is not sufficient. In fact, you have to add the icons in the Drawables folders. I located the drawables folders: platforms/android/res, and added the icon I want to show with the push notification in every folder. Then I added the code in the init line, but initially got nothing. The only way it worked was with a transparent icon. However, even with the transparent icon, it does not work as supposed to, as the icon turns all white and has a gray background.

What I want is a white background and the icon with its original colour, or being able to show the icon in its original form.

Another strange point is the fact that the nameoftheicon.png does not work with Android, but works with iOS. In the Android case, nameoftheicon suffices.

Did someone encounter such an issue with the new push plugin? What do you suggest?

This is the code of the init:

pushNotification = PushNotification.init({
    "android": { "senderID": GCM_SENDER_ID, "icon": "logo"},
    "ios": { "alert": "true", "badge": "false", "sound": "false", "icon": "logo.png" }, "windows": {}
});
2
About on android not using the .png... From the docs: android.icon Optional. The name of a drawable resource to use as the small-icon. The name should not include the extension.jcesarmobile
Are you using CLI, SDK or Build ? Please do not assume the answer, please read the link. Once you have answer the question, respond in the comments so I know you have added information to the post.user3255670

2 Answers

1
votes

Add your icon to every folder into this folders in res, in png

res/drawable-hdpi/icon_notification.png res/drawable-ldpi/icon_notification.png res/drawable-xhdpi/icon_notification.png etc

And make yout init like this:

that.push = PushNotification.init({ 
                        "android": {
                            "senderID": that.GOOGLE_SENDER_ID,
                            "iconColor": "gray",
                            "icon": "icon_notification"
                        },
                        "ios": {}, 
                        "windows": {} 
                });

This works for me.

Also, the icon is showed in black and white, so you should play with transparencies to show what you want, and i am using a 92x92 png, if this helps you

0
votes

I had the same problem too and the hacky way was to change the target android API to 20 and then my nice colorful icon appeared back in notification bar.