question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[android] Cannot set custom notification icon

See original GitHub issue
  1. What version of RN and react-native-fcm are you running? 11.2.0
  2. What device are you using? (e.g iOS9 emulator, Android 6 device)? Android 8.0 (OnePlus 5)
  3. Is your app running in foreground, background or not running? background / not running

I am trying to change the notification icon. But so far I have not been able to do that. I have read tons of articles about this, but I have no idea what’s wrong with my setup. Everything else works as expected.

AndroidManifest.xml

<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_notification" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/primary" />

The colour is actually working and I see the notification icons tinted:

message statusbar

But they do not have the expected shape. I tried several things.

  • I tried to copy the icons from the firebase example project.
  • I created custom icons and added them to mipmap and drawables
files

None of that worked so far. If anyone has an idea what might be wrong, I would be very happy for any hint / help. What’s really weird is that android-shaped icon with the droid. I have no idea where that is coming from.

Icon sizes are according to those guides:

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Titozzzcommented, Mar 1, 2018

There is effectively a bug with the version 11.8.0, just downgrade to 11.6.2

1reaction
jasperkuperuscommented, May 18, 2018

Had the same issue. Don’t downgrade, you can upgrade all google/firebase dependencies to 15+. My list of dependencies:

force "com.google.firebase:firebase-messaging:15.0.2"
force "com.google.firebase:firebase-core:15.0.2"
force "com.google.android.gms:play-services-gcm:15.0.1"
force "com.google.android.gms:play-services-base:15.0.1"
force "com.google.android.gms:play-services-maps:15.0.1"
force "com.google.android.gms:play-services-auth:15.0.1"
force "com.google.android.gms:play-services-auth-api-phone:15.0.1"
force "com.google.android.gms:play-services-auth-base:15.0.1"
force "com.google.firebase:firebase-analytics:15.0.2"
force "com.google.firebase:firebase-invites:15.0.1"

I also had to update react-native-firebase to 4.2.0 in the process. Check out their releases page and go back to your version and work your way back to 4.2.0 with breaking changes and upgrade notes:

4.0.0 and 4.2.0 are the most important parts, containing information on upgrading gradle to 4.4. For me it wasn’t directly clear I had to change all compile parts to implementation in android/app/build.gradle. Also. I had to add flavorDimensions after upgrading gradle:

Last but not least. Check if your iOS build still works. I had to update cocoapods and some react-native-firebase initialization code.

But after that, my push icon worked 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Icon not displaying in notification, white square shown instead
Right-click on your res folder > New > Image Asset. You will then see Configure Image Assets as shown in the image below....
Read more >
Can't Change Default Notification Icon In Android? · Issue #1077
Description: I'm trying to change the default notification "bell icon" in the app. I'm following this guide from Documentation.
Read more >
Android: Notification Icons - OneSignal Documentation
Adding custom icons to some or all of your notifications. Works with Android (and ... If you do not set a large icon,...
Read more >
Customizing notifications - Android / Advanced - Batch
Setting up custom push icons. Overview. Android lets you customise the way your notifications look: ... Here's how to set a custom large...
Read more >
Create a Custom Notification Layout | Android Developers
If you need a custom layout, you can apply NotificationCompat.DecoratedCustomViewStyle to your notification. This API allows you to provide a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found