Change Push Notification background color on Android 12

Viewed 41

I want to achieve something like Myntra App Notifications where i can change the background color of my notification in Android 12

Since Android 12 have restricted custom notifications how can we set the color for whole notification?

Myntra notification Android 12

1 Answers

You can't directly customize Push notifications. What you can do is override onMessageReceived() in your service that extends FireBaseMessagingService, and then create a local custom notification with whatever background color you want.

Edit: If you're asking how to apply a background color to local notifications, you need to set both of the following in the Notification Builder:

.setColor(resources.getColor(R.color.yourBgColor))
.setColorized(true)

and if that doesn't work for some reason, you'll need to create a custom notification layout in XML with the background color you want, and then

.setCustomContentView(notificationView)
Related