通知生成器没有收到完整的上下文

Notification Builder not receiving full context

我正在使用以下通知生成器代码,通过 firebase 云功能在 android 设备上接收通知。我成功收到通知。但是通知的上下文并不完全可见,如您在图像中所见。

左上角图标显示为灰色,未显示实际图标,文字显示不完整。

我应该如何纠正以上问题?

通知生成器

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);

我建议您阅读 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"))

应用NotificationCompat.BigTextStyle以在通知的扩展内容区域中显示文本。请访问Add a large block of text.

官方指南

仅供参考

Android 只要收到的邮件没有明确设置图标或颜色,就会使用这些值。

<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" />

阅读关于 Set up a Firebase Cloud Messaging client 的官方指南。