Skip to content

Commit

Permalink
fix: generate default advertising ID using UUID to avoid typos
Browse files Browse the repository at this point in the history
  • Loading branch information
comfrt1k committed Jan 10, 2025
1 parent ddc4352 commit 8a1f636
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ package com.personalization.sdk.data.repositories.advertising
import android.content.Context
import com.google.android.gms.ads.identifier.AdvertisingIdClient
import com.personalization.sdk.domain.repositories.AdvertisingRepository
import java.util.UUID
import javax.inject.Inject

private const val DEFAULT_ADVERTISING_ID = "00000000-0000-0000-0000-000000000000"

class AdvertisingRepositoryImpl @Inject constructor(
private val context: Context
) : AdvertisingRepository {
override suspend fun fetchAdvertisingId(): String =
try {
AdvertisingIdClient.getAdvertisingIdInfo(context).id
} catch (e: Exception) {
DEFAULT_ADVERTISING_ID
generateDefaultAdvertisingId()
}

private fun generateDefaultAdvertisingId(): String {
return UUID(0L, 0L).toString()
}

}

0 comments on commit 8a1f636

Please sign in to comment.