Firebase Invalid Notification small icon

0

I am trying to show notification in the app. App show notification when background or foreground But the App crash when app not clear from app background stack. I don't know why it happens. below is my app notification code Any Help will be Appreciated.

if (VERSION.SDK_INT >= 26) {
    notif = (new android.app.Notification.Builder(this, this.getString(string.notification_channel_id))).setSmallIcon(notificationResId).setContentTitle(title).setStyle((new BigTextStyle()).bigText(this.mText == null ? "" : this.mText)).setContentText(this.mText == null ? "" : this.mText).setVisibility(0).setChannelId(this.getString(string.notification_channel_id)).setAutoCancel(true);
} else {
    mBuilder = (new Builder(this)).setContentTitle(title).setSmallIcon(notificationResId).setStyle((new android.support.v4.app.NotificationCompat.BigTextStyle()).bigText(this.mText == null ? "" : this.mText)).setContentText(this.mText == null ? "" : this.mText).setAutoCancel(true).setDefaults(-1);
}

if (VERSION.SDK_INT >= 26) {
    notif.setContentIntent(contentIntent);
    this.mNotificationManager.notify(id, notif.build());
} else {
    mBuilder.setContentIntent(contentIntent);
    this.mNotificationManager.notify(id, mBuilder.build());
}

Error:

java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(pri=0 contentView=null vibrate=default sound=default defaults=0xffffffff flags=0x11 color=0x00000000 vis=PRIVATE semFlags=0x0 semPriority=0)

android
push-notification
asked on Stack Overflow Oct 15, 2018 by tech_android • edited Oct 15, 2018 by Frank van Puffelen

1 Answer

0

Add this meta in your manifest in 'application'

<meta-data
         android:name="com.google.firebase.messaging.default_notification_icon"
         android:resource="@mipmap/ic_hello" />
answered on Stack Overflow Oct 15, 2018 by Daniel Carreto

User contributions licensed under CC BY-SA 3.0