Skip to content

Instantly share code, notes, and snippets.

@Ayush783
Created February 1, 2024 08:23
Show Gist options
  • Save Ayush783/ff5878db35f18999064647cf3de214ba to your computer and use it in GitHub Desktop.
Save Ayush783/ff5878db35f18999064647cf3de214ba to your computer and use it in GitHub Desktop.
Setting unique group key for each notification
createNotification() {
...
notificationBuilder.setGroup(getUniqueGroupKey(10))
...
}
fun getUniqueGroupKey(sizeOfRandomString: Int): String {
val random = Random()
val sb = StringBuilder(sizeOfRandomString)
for (i in 0 until sizeOfRandomString)
sb.append(ALLOWED_CHARACTERS[random.nextInt(ALLOWED_CHARACTERS.length)])
return sb.toString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment