Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I override default push notification icon in android from app icon to custom icon?

Can I override default push notification icon in android from app icon to custom icon?

I am using default firebase implementation to display notification in system tray, when a push notification come. Since my app icon is coloured and has gradient, so when a notification comes, android tried to make a black/white version of it, and make it look like a white circle.

Is there a way to update the default notification icon to something else instead of default app icon?

PS: Looking forward for a solution which required a config change in manifest and don't want to use NotificationCompat.Builder

like image 814
Shashank Avatar asked Jun 09 '16 10:06

Shashank


People also ask

How do I change the notification icon on my Android?

1 Tap Notification Settings on the notification panel or tap the Settings app. 2 Tap Notifications. 3 Tap App icon badges.

How do I make custom push notifications?

1. Configure custom push notifications in the Dashboard. You can configure Helpshift to send the push notification message to a custom URL instead of through APNS (For iOS) and FCM/GCM (for Android). The first step to do so is for an Admin to set up a custom push notification.

Are Android push notifications default?

The key differentiator is that getting push notifications are the default for Android apps. For iOS, the user is prompted to allow notifications when they first open a new app, so the default is not getting push notifications for any given app.


Video Answer


2 Answers

you can use this in your manifest according to https://firebase.google.com/docs/cloud-messaging/android/receive

    <!-- Set custom default icon. This is used when no icon is set for incoming notification
    messages.See README(https://github.com/firebase/quickstart-android/tree/master/messaging#custom-default-icon) for more. -->
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/ic_stat_ic_notification" />

    <!-- Set color used with incoming notification messages.
    This is used when no color is set for the incoming notification message. See README
    (https://github.com/firebase/quickstart-android/tree/master/messaging#custom-default-color) for more. -->
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorAccent" />

Hope it helps people.

like image 152
elsennov Avatar answered Oct 21 '22 05:10

elsennov


You can set

  .setSmallIcon(int);
  .setLargeIcon(bitmap);

A small icon, set by setSmallIcon()

NotificationCompat.Builder setLargeIcon (Bitmap icon)

Set the large icon that is shown in the ticker and notification.

in NotificationCompat.Builder.

Documentation - https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html

like image 2
kalpana c Avatar answered Oct 21 '22 06:10

kalpana c