显示灰色的推送通知图标

Arv*_*iya 1 c# android xamarin.android firebase xamarin

在我的应用 Firebase 推送通知未正确显示图标,它在通知中显示全灰色图标。我用于实现通知的代码

var notificationBuilder = new Notification.Builder(this)
.SetSmallIcon(Resource.Drawable.ic_launcherLmg)
.SetContentTitle(user.Organization)
.SetSubText(user.ModuleName)
.SetContentText(user.BodyText)
.SetAutoCancel(true)
.SetContentIntent(pendingIntent)
.Build();
Run Code Online (Sandbox Code Playgroud)

图标我SetSmallIcon(Resource.Drawable.ic_launcherLmg)在线设置。ic_launcherLmg 图标可在给定尺寸的以下文件夹中找到

  1. drawable-idpi--36x36
  2. drawable-mdpi--48x48
  3. drawable-hdpi--72x72
  4. drawable-xhdpi--96x96

应用程序以最高 8.1 API 为目标。最小 5.0 API。

推送通知截图

在此处输入图片说明

mah*_*aja 5

也许你的图标没有在背景 fcm push 中显示?所以,你需要把里面的清单这里面的应用程序标记为这里所描述这里

<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/ic_launcherLmg" />
Run Code Online (Sandbox Code Playgroud)

对于未明确设置通知图标的所有通知消息,Android 会显示此自定义默认图标。