-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUID2GMAMediationAdapter.swift
More file actions
71 lines (59 loc) · 2.04 KB
/
Copy pathUID2GMAMediationAdapter.swift
File metadata and controls
71 lines (59 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// UID2GMAMediationAdapter.swift
//
//
// Created by Brad Leege on 3/20/23.
//
import Foundation
import GoogleMobileAds
import UID2
/// Adapter to connect UID2 to Google Mobile Ads
/// https://developers.google.com/admob/ios/open-bidding-adapter
@available(iOS 13, *)
@objc(UID2GMAMediationAdapter)
class UID2GMAMediationAdapter: NSObject {
required override init() { }
}
@available(iOS 13, *)
extension UID2GMAMediationAdapter: RTBAdapter {
static func setUp(with configuration: MediationServerConfiguration, completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock) {
guard isOperatingSystemSupported else {
completionHandler(OperatingSystemUnsupportedError())
return
}
// Ensure UID2Manager has started
_ = UID2Manager.shared
completionHandler(nil)
}
func collectSignals(for params: RTBRequestParameters, completionHandler: @escaping GADRTBSignalCompletionHandler) {
guard isOperatingSystemSupported else {
completionHandler(nil, OperatingSystemUnsupportedError())
return
}
Task {
guard let advertisingToken = await UID2Manager.shared.getAdvertisingToken() else {
completionHandler(nil, AdvertisingTokenNotFoundError())
return
}
completionHandler(advertisingToken, nil)
}
}
static func adapterVersion() -> VersionNumber {
var version = VersionNumber()
version.majorVersion = 3
version.minorVersion = 0
version.patchVersion = 1
return version
}
static func adSDKVersion() -> VersionNumber {
let uid2Version = UID2SDKProperties.getUID2SDKVersion()
var version = VersionNumber()
version.majorVersion = uid2Version.major
version.minorVersion = uid2Version.minor
version.patchVersion = uid2Version.patch
return version
}
static func networkExtrasClass() -> AdNetworkExtras.Type? {
return nil
}
}