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 - problem with custom notification icon + notification icon color on light status bar #290

Closed
Nico924 opened this issue May 28, 2017 · 6 comments

Comments

@Nico924
Copy link

Nico924 commented May 28, 2017

  1. I tried to use what is in the last readme file to set a custom icon for my notifications.
    However while i wrote the two following lines in the values/styles.xml (+ values-v21), it keeps setting the default app application icon if I send a random notification using the firebase console (https://console.firebase.google.com).
    <drawable name="notification_big">@drawable/notif_icon</drawable>
    <drawable name="notification_icon">@drawable/notif_icon</drawable>

However, if I tell firebase the icon I want through a custom parameter (I tell him to use notif_icon in my case), then it works, the custom icon is displayed.
(same consideration for for the accent color. It works through firebase but not using the colors.xml file in values)

To summarize what I have:
cordova-android 6.2.3
cordova-plugin-firebase 0.1.21
Android version 7.0

In the res/ folder

  • notif_icon.png in the drawable/ folder (not in the suffix folders, I also tried to copy it in every dpi folders, nothing changed)
  • in values/colors.xml (red to test)
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <color name="accent">#8B0000</color>
    </resources>
  • in values/styles.xml
    <?xml version="1.0" encoding="utf-8" ?>
    <resources>
    <!-- inherit from the holo theme -->
    <style name="AppTheme" parent="android:Theme.Light">
    <item name="android:windowDisablePreview">true</item>
    </style>
    <drawable name="notification_big">@drawable/notif_icon</drawable>
    <drawable name="notification_icon">@drawable/notif_icon</drawable>
    </resources>

In AndroidManifest
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />

  1. I also read that in order to have a notification icon that becomes grey if the status bar is light. You have to add in the values-v23/styles.xml file the following line
    <item name="android:windowLightStatusBar">true</item>
    (from here https://stackoverflow.com/questions/35119021/invert-icon-color-of-status-bar)

So I also created a values-v23/styles.xml file like this
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<item name="android:windowDisablePreview">true</item>
<item name="android:windowLightStatusBar">true</item>
</style>
<drawable name="notification_big">@drawable/notif_icon</drawable>
<drawable name="notification_icon">@drawable/notif_icon</drawable>
</resources>
`
Once again, it does nothing. If someone could explain me what I'm doing wrong, it would be very great !

Thank you in advance

@LufoX11
Copy link

LufoX11 commented May 29, 2017

My solution #53 (comment)

@Nico924
Copy link
Author

Nico924 commented May 29, 2017

@shamank thank you, it solved my first problem :)
However have you a solution for the second point, the one about the notification icon color that does not become grey on light notification bar (for exemple the app messages or google agenda) ?

@LufoX11
Copy link

LufoX11 commented Jun 9, 2017

@Nico924 Sorry man, I've not been around these days.

However have you a solution for the second point, the one about the notification icon color that does not become grey on light notification bar (for exemple the app messages or google agenda) ?

Sadly not :( BTW and just for further use, did you find a solution to this?

@tgensol
Copy link

tgensol commented Jun 14, 2017

@Nico924 How did you solve your first issue ? thanks

@Nico924
Copy link
Author

Nico924 commented Jun 21, 2017

@shamank unfortunately no :/ However, It appears that you can use colorful icons (at least it worked on my Samsung when I had Android 6 and now with Android 7 as well) so the idea is to use a color that works both on dark and white background haha but I know it does not follow the Android guidelines but who cares ? :p
@tgensol There is two way of doing that, the easiest is to use send the name of the resource you want to use in your drawable folder along with your notification sent from your backend thanks to the firebase api (more info here).
The second one is to add custom configuration lines in your Manifest using either the custom-config plugin or by writing in the manifest directly these two lines
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_message_notification" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/accent" />
This will update the default notification icon and color of your app (but it will still be overridden if you use the first solution)
More info about the default notification icon and color here

@soumak77
Copy link
Contributor

soumak77 commented May 4, 2018

closing as resolved

@soumak77 soumak77 closed this as completed May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants