Notification Builder not receiving full context

Rajni Tandon :

I am using below code for notification builder for receiving notification on android device from through firebase cloud function. I am receiving notification successfully. but The context of the notification is not completely visible as you can see in the image.

On the top left icon is displayed as grey and not showing the actual icon and the text is not shown completely.

How should I rectify the above issues?

Notification Builder

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, ADMIN_CHANNEL_ID)
                .setSmallIcon(R.drawable.finalicon)
                .setLargeIcon(largeIcon)
                .setContentTitle(messageTitle)
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(notificationSoundUri)
                .setContentIntent(pendingIntent);

Notification Image

IntelliJ Amiya :

I would kindly suggest you to read NotificationCompat.BigTextStyle.

Helper class for generating large-format notifications that include a lot of text. If the platform does not provide large-format notifications, this method has no effect. The user will always see the normal notification view.

 .setStyle(new NotificationCompat.BigTextStyle().bigText("YourText"))

Apply NotificationCompat.BigTextStyle to display text in the expanded content area of the notification. Kindly visit official guide line about Add a large block of text.

FYI

Android uses these values whenever incoming messages do not explicitly set icon or color.

<meta-data
    android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/your_image" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
     notification message.  -->
<meta-data
    android:name="com.google.firebase.messaging.default_notification_color"
    android:resource="@color/colorAccent" />

Read official guideline about Set up a Firebase Cloud Messaging client.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=408728&siteId=1