When I open the app and receive the notification, my custom notification shows.
But when the app is in the background, it just uses the default notification setting. I'm trying to change the icon of the notification from that dot to my app logo.
My FirebaseMessagingService code is below
public static final String TG = "FCMService";
NotificationManagerCompat notificationManager;
@Override
public void onNewToken(@NonNull String s) {
Log.i(TG, "The token refreshed: " + s);
super.onNewToken(s);
}
@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if(remoteMessage.getData().size() > 0)
{
Log.d(TG, "Message data payload : " + remoteMessage.getData());
}
if(remoteMessage.getNotification() != null)
{
Log.d(TG, "Message notification body : " + remoteMessage.getNotification().getBody());
}
Log.d(TG, "From : " + remoteMessage.getFrom());
Map<String, String> s = remoteMessage.getData();
sendNotification(s.get("message"));
}
private void sendNotification(String message) {
notificationManager = NotificationManagerCompat.from(this);
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 ,intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(this, CHANNEL_1_ID)
.setSmallIcon(R.drawable.ic_07c1b5098af03f95f3c3e8f7d461fb78)
.setContentTitle("Just In")
.setContentText(message)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(pendingIntent)
.build();
notificationManager.notify(1, notification);
}
And my Manifest file is
<service
android:name=".MyFirebaseMessagingService"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>