Why do some android apps have option to show notification number on icon badge and others don't?

Viewed 24

Phone specs

Realme 3 Pro
Android 11

Left one is Whatsapp and right one is Telegram. enter image description here

1 Answers

That is because when you are creating the app as a developer, you can choose how the notifications will be displayed.

So, the Telegram Developer's Team chose to disable the "Bubble" notification Or to be more precise, the Whatsapp Developer's Team chose to enable it because by default the option of "Bubble" notification is disabled in the framework.

Notification notification = new NotificationCompat.Builder(context, CHANNEL_ID)
        .setContentTitle(getNewMessagesCount(message) + " new messages with " + person.getName())
        .setCategory(Notification.CATEGORY_MESSAGE)
        .setContentText(message.text)
        .setBubbleMetadata(
                new NotificationCompat.BubbleMetadata.Builder()
                        .setDesiredHeight(600)
                        .setIntent(bubbleIntent)
                        .setAutoExpandBubble(true)
                        .setSuppressNotification(true)
                        .setIcon(icon)
                        .build()
        )
        .addPerson(person)
        .setSmallIcon(R.mipmap.ic_launcher_round)
        .setWhen(message.date)
        .setStyle(style)
        .setShortcutInfo(
                new ShortcutInfoCompat.Builder(context, message.conversationId + "")
                        .setActivity(new ComponentName(context, ChatActivity.class))
                        .setCategories(new HashSet<>(Collections.singletonList(Notification.CATEGORY_MESSAGE)))
                        .setIcon(icon)
                        .setPerson(person)
                        .setRank(0)
                        .setShortLabel(person.getName())
                        .setIntent(intent)
                        .build()
        )
        .build();

https://developer.android.com/develop/ui/views/notifications/build-notification#java

Follow this link to manage bubble on your notification : https://developer.android.com/develop/ui/views/notifications/bubbles

Related