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.
you could generate the local notification with custom count.
example :
Android Doc
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());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With