Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Notification Icon Background Color Issue #2469

Open
MSL-BIT opened this issue Nov 18, 2024 · 4 comments
Open

Android Notification Icon Background Color Issue #2469

MSL-BIT opened this issue Nov 18, 2024 · 4 comments

Comments

@MSL-BIT
Copy link

MSL-BIT commented Nov 18, 2024

Describe the bug
The bug occurs on Android: the color specified via the "color" attribute is applied correctly only in light mode. In dark mode, the color is overridden, and a different color is displayed.

To Reproduce

  1. Enable dark mode on your Android device.
  2. Open the affected component or screen where the "color" attribute is used.
  3. Observe the displayed color.
  4. Switch to light mode and compare the color.

Expected behavior
The color specified via the "color" attribute should remain consistent across light and dark modes. Or is adjustable also for dark mode.

Current Implementation

  late AndroidNotificationDetails androidNotificationDetails = AndroidNotificationDetails(
    icon: androidAppIconName,
    color: const Color(0x001d1d1d),
    androidNotificationChannelId,
    androidNotificationChannelName,
    importance: Importance.max,
    priority: Priority.high,
  );

Light Mode:
image

Dark Mode:
image

@Levi-Lesches
Copy link
Contributor

I don't have a solid source for this, but apparently in dark mode, android will override your color if it determines it's not readable against a dark background. In your case, your color is near black, so it gets changed. You wouldn't want your "regular" color to be shown in dark mode

Advice around the Internet suggests using a white icon in your assets and coloring it with code, changing the color depending on the device's current mode

@MaikuB
Copy link
Owner

MaikuB commented Nov 29, 2024

@MSL-BIT unless you can find a source that says otherwise, I don't believe there's a bug. This is based on how all the plugin does is call this method so what you see is what you get as the plugin has no other logic around this

@sai-chandra22
Copy link

sai-chandra22 commented Dec 13, 2024

Hi guys, so is there any other way to change the notifications background color, and change icon of our choice for both IOS and Android?

@Levi-Lesches
Copy link
Contributor

As I mentioned, android takes over this process in dark mode, so you have no control there. Perhaps you can use a runtime check to see if the user is in dark mode and supply a different icon, but your best bet is usually you use a monochromatic icon. That way, whatever color it is shown in will look good.

I don't use iOS, but I haven't found anything about iOS supporting different icon options, so it looks like the answer is no there too.

Again, these are both limitations of the platforms themselves, not this plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants