[英]Push Notifications icon displaying gray color
在我的應用程序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();
我正在SetSmallIcon(Resource.Drawable.ic_launcherLmg)
行設置的圖標。 ic_launcherLmg圖標位於以下文件夾中,並帶有dimensoins
應用包含最高8.1 API。 Minimun 5.0 API。
推送通知的屏幕截圖
也許您的圖標沒有通過背景fcm推送顯示? 因此,你需要在此描述放在這里面的應用程序標簽中體現在這里 :
<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_launcherLmg" />
對於未明確設置通知圖標的所有通知消息,Android都會顯示此自定義默認圖標。
您可以使用
使用mipmap圖標而不是可繪制圖標,然后將其放在xxxhdpi-mipmap文件夾中。 如果背景為白色,圖標將自動調整其顏色
要么
使用通知圖標作為android版本,例如
.SetSmallIcon(getNotificationIcon())
功能是或根據需要更改它
private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.drawable.icon_silhouette : R.drawable.ic_launcher;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.