Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Source/OptableSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,10 @@ extension OptableSDK {
ATT.advertisingIdentifier != UUID(uuid: uuid_t(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) {
let systemIDFA = ATT.advertisingIdentifier.uuidString

// Remove all matching systemIDFA (deduplicate)
// Remove all matching systemIDFA (deduplicate), compared as encoded so case and whitespace don't matter
let systemEID = OptableIdentifier.appleIDFA(systemIDFA).extendedIdentifier
ids.removeAll { id in
if case let .appleIDFA(value) = id { return value == systemIDFA }
if case .appleIDFA = id { return id.extendedIdentifier == systemEID }
return false
}

Expand Down
22 changes: 22 additions & 0 deletions Tests/Unit/OptableSDKHelpersIdentifiersEnrichmentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,28 @@ class OptableSDKHelpersIdentifiersEnrichmentTests: XCTestCase {
}
}

func test_idfa_detection_enabled_enrich_system_idfa_same_as_lowercased_user_idfa_prepend() {
ATT.advertisingIdentifierAvailable_DebugOverride = true
ATT.advertisingIdentifier_DebugOverride = UUID(uuidString: systemIDFA)

var identifiers = buildIdentifiers()
identifiers.append(.appleIDFA(" " + systemIDFA.lowercased()))

let sdk = buildSDK()
sdk.config.skipAdvertisingIdDetection = false
sdk.enrichIfNeeded(ids: &identifiers)

if case let .appleIDFA(value) = identifiers[0] {
XCTAssert(value == systemIDFA, "Prepended IDFA is not the same as system provided")
} else {
XCTFail("System IDFA is not prepended")
}

if identifiers.count(where: { if case .appleIDFA = $0 { return true } else { return false } }) > 1 {
XCTFail("User IDFA persists. (duplicate)")
}
}

func test_idfa_detection_enabled_enrich_system_idfa_user_idfa_persist() {
ATT.advertisingIdentifierAvailable_DebugOverride = true
ATT.advertisingIdentifier_DebugOverride = UUID(uuidString: systemIDFA)
Expand Down
Loading