Skip to content
Merged
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
2 changes: 1 addition & 1 deletion UID2Prebid.podspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"~> 1.3.0"
],
"PrebidMobile": [
"~> 2.0"
"~> 2.4"
]
}
}
2 changes: 1 addition & 1 deletion UID2Prebid/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "prebid/prebid-mobile-ios" "2.2.3"
github "prebid/prebid-mobile-ios" "2.4.0"
2 changes: 1 addition & 1 deletion UID2Prebid/Carthage/Checkouts/prebid-mobile-ios
Submodule prebid-mobile-ios updated 369 files
12 changes: 9 additions & 3 deletions UID2Prebid/UID2Prebid/UID2Prebid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ protocol UserIDUpdater: Sendable {
struct PrebidUserIDUpdater: UserIDUpdater {
/// Passes the observed IDs to Prebid
func updateUserIDs(_ userIDs: [ExternalUserId]) {
Prebid.shared.externalUserIdArray = userIDs
Targeting.shared.setExternalUserIds(userIDs)
}
}

public actor UID2Prebid: Sendable {
let thirdPartyUserIDs: @Sendable () async -> [ExternalUserId]
let userIDUpdater: UserIDUpdater

// https://github.com/InteractiveAdvertisingBureau/AdCOM/blob/main/AdCOM%20v1.0%20FINAL.md#list_agenttypes
// "A person-based ID, i.e., that is the same across devices."
private let agentType: NSNumber = 3
private let source = "uidapi.com"
private var task: Task<Void, Never>?

Expand Down Expand Up @@ -72,8 +76,10 @@ public actor UID2Prebid: Sendable {
func updateExternalUserID(_ advertisingToken: String?) async {
var userIDs = await self.thirdPartyUserIDs()
if let advertisingToken {
let advertisingTokenUser = ExternalUserId(source: source, identifier: advertisingToken)
userIDs.append(advertisingTokenUser)
userIDs.append(ExternalUserId(
source: source,
uids: [.init(id: advertisingToken, aType: agentType)]
))
}
await userIDUpdater.updateUserIDs(userIDs)
}
Expand Down
18 changes: 11 additions & 7 deletions UID2Prebid/UID2PrebidTests/UID2PrebidTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ final class UID2PrebidTests: XCTestCase {
}
)
await observation(
of: [ExternalUserId(source: "uidapi.com", identifier: "cat")],
of: [
ExternalUserId(source: "uidapi.com", uids: [.init(id: "cat", aType: 1)])
],
by: updater
)

Expand All @@ -65,7 +67,9 @@ final class UID2PrebidTests: XCTestCase {
.established(.established(advertisingToken: "turtle"))
)
await observation(
of: [ExternalUserId(source: "uidapi.com", identifier: "turtle")],
of: [
ExternalUserId(source: "uidapi.com", uids: [.init(id: "turtle", aType: 1)])
],
by: updater
)
}
Expand All @@ -89,7 +93,7 @@ final class UID2PrebidTests: XCTestCase {
manager: manager,
thirdPartyUserIDs: {
[
ExternalUserId(source: "example.com", identifier: "dog")
ExternalUserId(source: "example.com", uids: [.init(id: "dog", aType: 1)])
]
},
userIDUpdater: updater,
Expand All @@ -102,16 +106,16 @@ final class UID2PrebidTests: XCTestCase {
)
await observation(
of: [
ExternalUserId(source: "example.com", identifier: "dog"),
ExternalUserId(source: "uidapi.com", identifier: "cat"),
ExternalUserId(source: "example.com", uids: [.init(id: "dog", aType: 1)]),
ExternalUserId(source: "uidapi.com", uids: [.init(id: "cat", aType: 1)]),
],
by: updater
)

continuation.yield(.invalid)
await observation(
of: [
ExternalUserId(source: "example.com", identifier: "dog"),
ExternalUserId(source: "example.com", uids: [.init(id: "dog", aType: 1)]),
],
by: updater
)
Expand Down Expand Up @@ -141,7 +145,7 @@ extension UID2PrebidTests {
}
struct ExternalUserIdEquatable: Equatable {
var source: String
var identifier: String
var identifier: String?
var atype: Int?

init(_ userId: ExternalUserId) {
Expand Down