Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Android: Notification icon problem #20

Closed
quedicesebas opened this issue Jun 19, 2015 · 24 comments
Closed

Android: Notification icon problem #20

quedicesebas opened this issue Jun 19, 2015 · 24 comments

Comments

@quedicesebas
Copy link

In lollipop, My notification look like this:

In the notification bar, it's a white square (with the old plugin, the same app icon was used here):

screenshot_2015-06-19-13-36-53

Notification bar expanded, a circle with the app icon inside (there's no way make somethinh better, like the other apps?):

screenshot_2015-06-19-13-37-00

@macdonst macdonst added the bug label Jun 22, 2015
@macdonst
Copy link
Member

@sebrojas14 upon having the chance to look into this bug I believe it not to be a bug. In Android Lollipop there were changes to the notifications so all icons show up as white. See the following url: https://developer.android.com/design/patterns/notifications.html

I think the best way forward for you is to add a transparency to your icon so that it your icon shows up as a silhouette of a person. Potentially we need to add another icon into cordova/phonegap.

@quedicesebas
Copy link
Author

Yes, you're right. But I need the app icon to have a white background. So, you would be nice a a way to specify a different icon for notifications, or even better, the option of use icons with badge like skype and inbox in the image

@macdonst macdonst added enhancement and removed bug labels Jun 22, 2015
@macdonst
Copy link
Member

@sebrojas14 so the way that it works on Android is you can specify a small icon and large icon in the notification. As you can see in this screen shot:

Screenshot

You can see the PhoneGap Enterprise is the large icon and the cordova build bot is the small icon. I can add in the large icon support but we don't have a good way of specifying it right now. I'm changing this to an enhancement for now.

@quedicesebas
Copy link
Author

So for now, is not possible to specify a different icon for the notifications?

@macdonst
Copy link
Member

@sebrojas14 no, not at the moment but my plan is to add a option in the android setup to provide an icon to use instead of the main app icon. If not icon is provide it will use the main app icon as a fallback.

@quedicesebas
Copy link
Author

I'll wait for it! thank you

@macdonst macdonst added this to the Release 1.1.0 milestone Jun 28, 2015
@ivanmayes
Copy link

+1 this would be extremely helpful, white square are no fun!

@michael-may
Copy link

+1

Tested the TargetSDK workaround and it brings the full icon back for now at least.

In your config.xml:

<platform name="android">
   ...
   <preference name="android-targetSdkVersion" value="19"/>
</platform>

@ashconnell
Copy link
Contributor

+1 Waiting for this also, we switched to this plugin because the PushPlugin repo is insanely outdated.

@ashconnell
Copy link
Contributor

@michael-may The target SDK workaround is not a very graceful fix.

@macdonst
Copy link
Member

This is coming tonight or tomorrow. I just need to document it:

Large icon support
supports url, asset or drawable

Small icon support
Set the drawable via the Android options. Defaults to app icon if nothing is passed in. As well, you can set the background color for the icon.

New hotness

@quedicesebas
Copy link
Author

Nice! And what is the icon used in the notification bar?

@macdonst
Copy link
Member

@sebrojas14 the small icon, specified at init time.

@macdonst
Copy link
Member

2015-07-24 02 17 55
2015-07-24 02 20 02
2015-07-24 02 34 41
2015-07-24 02 46 58
2015-07-24 02 52 00

@quedicesebas
Copy link
Author

Sorry, I was asking for the status bar.

@macdonst
Copy link
Member

@sebrojas14 Yes, when you specify an icon via init it is used in the status bar as well. I just pushed the code so try it out and I'm planning on bumping the plugin version shortly. Much thanks to @Deminetix for his assistance on this issue.

@ashconnell
Copy link
Contributor

@macdonst did you miss my PR?

@ashconnell
Copy link
Contributor

Oh sorry, I missed that. Hope its helfpul to peeps :)

@macdonst
Copy link
Member

@Deminetix no, I didn't miss it. I used it but changed it up a bit. Again, I really appreciate you contributing to this plugin so keep at it.

@kentmw
Copy link

kentmw commented Oct 19, 2015

Just as a note to those like me using Phonegap Build to build your apk's, PGB currently doesn't let you add or copy images to the /res directory and because the NotificationBuilder specifically (at least in Lolipop and lower versions) requires a resource id, PGB users can not produce white/transparent icons unless your app icon itself fits the system icon/small icon/notification banner specifications.

Extra thoughts: I tried to fool PGB using qualifiers to the app icon and/or splash screen images to no avail. Also, it looks like in API level 23 (or code named M after Lolipop), you can generate icons programatically so you could pull an image in from www/ directory.

It looks like exploding your apk using a tool like apktool, adding the image to the res directory, and rebuilding it with -c flag is the only option - except perhaps dropping phonegap build altogether.

EDIT: ah, I see this is addressed in #118. Actually, almsot word for word...

@bguvenis
Copy link

What about the small blue icon on the bottom right of "Large Icon - Loaded from drawables folder"? How do you set that? I see a white square inside a turquois circle. I want to give an image for that, or clear it for good.

@rohit121
Copy link

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
https://blog.clevertap.com/fixing-notification-icon-for-android-lollipop-and-above/

Hope that helps

@pke
Copy link

pke commented Jun 17, 2016

I am using an icon with alpha channel now but the cordova build process for android modifies the icon and removes the alpha channel.

@lock
Copy link

lock bot commented Jun 4, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

9 participants