Created
February 1, 2024 08:23
-
-
Save Ayush783/ff5878db35f18999064647cf3de214ba to your computer and use it in GitHub Desktop.
Setting unique group key for each notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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