I used ShortcutBadger library for android but it is not working in my case. I tested it on various devices. I googled about it and possible solution can be use of widget. Is there any other solution? Apps like facebook whatsapp showing the badge count and that is visible in my phone.
Asked
Active
Viewed 5,466 times
4

Nadeem Aslam
- 123
- 1
- 7
1 Answers
2
you could generate the local notification with custom count.
example :
Kotlin:
var notification = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID)
.setContentTitle("New Messages")
.setContentText("You've received 3 new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
.setNumber(3)
.build()
Java:
Notification notification = new NotificationCompat.Builder(MainActivity.this, CHANNEL_ID)
.setContentTitle("New Messages")
.setContentText("You've received 3 new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
.setNumber(3)
.build();
following will trigger the notification.
NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, notificationBuilder.build());

Nakul
- 1,313
- 19
- 26