Search code examples
androidfirebasepush-notificationfirebase-cloud-messagingfirebase-notifications

What size can we use for the notification badge icon in FCM?


I am using FCM push notification for my app, everything is working fine. but right now, I am getting a small icon below my notification icon. See below image.

enter image description here

Can any one tell me what is the size we can use for this icon? And how can we customize it?How can i add icon or image at that place?


Solution

  • I tried this and it solved,sorry for late answer

        private void sendNotification(String messageBody,String titles) {
    
    
                Intent intent = new Intent(this, NotificationList.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
                        PendingIntent.FLAG_ONE_SHOT);
    
                Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.appicon);
    
                NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
    
                        .setContentTitle(titles)
                        .setLargeIcon(largeIcon)
                        .setContentText(messageBody)
                        .setAutoCancel(true)
                        .setSound(defaultSoundUri)
                        .setSmallIcon(getNotificationIcon())
                        .setContentIntent(pendingIntent);
    
                NotificationManager notificationManager =
                        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    
                notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
            }
    
    private int getNotificationIcon() {
            boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
            return useWhiteIcon ? R.mipmap.notismall : R.mipmap.appicon;
        }