Skip to content

Commit

Permalink
Remove duplicate entries in the notification token list.
Browse files Browse the repository at this point in the history
The application id coming from the app is generated using the
identifierForVendor iOS API. This can change for the same device
depending on varios factors (see the documentation)

So we will use the token from FCM to cleanup any duplicate entries.
  • Loading branch information
prasanthu committed Oct 22, 2019
1 parent ed599a4 commit 17be24e
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ object DocumentDataStoreSingleton : DocumentStore {
.getOrElse { emptyList() }

override fun addNotificationToken(customerId: String, token: ApplicationToken): Boolean {
// Remove any other entries with the same token.
getNotificationTokens(customerId).forEach {
if (it.tokenType == token.tokenType && it.token == token.token && it.applicationID != token.applicationID) {
removeNotificationToken(customerId, it.applicationID)
}
}
return notificationTokenStore.put(
token,
token.applicationID,
Expand Down

0 comments on commit 17be24e

Please sign in to comment.