2

I am using react-native, amplify, and pinpoint.

I have followed several guides and stack overflow questions to set the android default color and icon for push notifications like this:

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

I have a file colors.xml inside of android/app/src/main/res/values/ with this content:

<resources>
    <color name="patch_coral">#E97A6E</color>
</resources>

And for the icon I have drawable folders inside of android/app/src/main/res/ which contain the ic_notification.png generated in android asset studio as white icons as was instructed in several places.

I have also tested with debug and release builds to see if that would change anything; however, the push notifications still do not have the default icon or color, but it does have the app icon on the right side. Here is an example:

current android push notification example

What needs to be changed or added to get the color and icon to replace the default android color, and square icon?

Nathan Dullea
  • 343
  • 2
  • 6
  • 13

2 Answers2

5

First of all create your icon: - go to photoshop or https://pixlr.com/x/ and open new image (456*456 PX) - chose a black background (you can choose any color doesn’t meters, we will change it later from manifest - add the logo in the meddle

Like this

  • then cutout the logo (there is some tools with photoshop or pixlr to do this)
  • then save it as PNG)

Should look like this

Then go to manifest and choose the image as default notification icon and the color in default notification color that will wrok when the app in the background or killed Manifest

If you want to change to work when the app in foreground u should do this in your Firebase class

Firebase class

the results is: results

fadi Mashan
  • 111
  • 1
  • 3
  • Can you please check this [question](https://stackoverflow.com/questions/64582249/change-notification-default-icon-in-android) something related but with onesignal – Oliver D Oct 29 '20 at 11:11
0

What you need is to send this data through your push-notification.

Then read this data from the push notification payload and apply it to the notification Builder.

Karan Dhillon
  • 1,186
  • 1
  • 6
  • 14
  • The notification Builder is android specific code, do you know if it is possible to do the same thing using entirely amplify's push notification service? Or will I have to create a android native module to import and perform the set small icon and color? For reference here is the documentation for how amplify sets up and configures PNs: https://aws-amplify.github.io/docs/js/push-notifications#installation-and-configuration. – Nathan Dullea Apr 22 '20 at 16:56
  • Im not sure about 3rd party service's, but at the end of the day, the notification will be built by the android framework and you only have those attributes at your disposal that android opens up to you. A good choice is to have assets sent through the payload (every 3rd party would send a payload), and then use the contents of that payload to render or setup your notification. – Karan Dhillon Apr 22 '20 at 17:12