Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New EID usage #106

Merged
merged 2 commits into from
Apr 29, 2024
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
15 changes: 6 additions & 9 deletions Application/Sources/Rendering/NimbusAdManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ final class AdManagerViewController: SampleAdViewController {
private var customAdContainerView: CustomAdContainerView?
private var adController: AdController?
private lazy var requestManager = NimbusRequestManager()

// To backup existing interceptors to re-inject them at deinit
private let requestInterceptors: [NimbusRequestInterceptor]?
private var hasCompanionAd = false

init(adType: AdManagerAdType, headerSubTitle: String) {
self.adType = adType

// Unsetting interceptors to remove all Demand information to ensure only Nimbus renders
requestInterceptors = NimbusRequestManager.requestInterceptors
NimbusRequestManager.requestInterceptors = nil

super.init(headerTitle: adType.description, headerSubTitle: headerSubTitle)
NimbusRequestManager.requestInterceptors?.append(self)
}

required init?(coder: NSCoder) {
Expand All @@ -46,8 +39,12 @@ final class AdManagerViewController: SampleAdViewController {
setupCustomVideoSettings()
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
NimbusRequestManager.requestInterceptors?.removeAll { $0 === self }
}

deinit {
NimbusRequestManager.requestInterceptors = requestInterceptors
let nimbusAdView = contentView.subviews.first(where: { $0 is NimbusAdView }) as? NimbusAdView
nimbusAdView?.destroy()
customAdContainerView?.destroy()
Expand Down
2 changes: 1 addition & 1 deletion Application/Sources/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ extension UserDefaults {
set(newValue, forKey: #function)
if newValue && nimbusTestMode && NimbusAdManager.extendedIds?.first(where: { $0.source == "tradedesk.com" }) == nil {
var extendedIds = NimbusAdManager.extendedIds ?? []
extendedIds.insert(NimbusExtendedId(source: "tradedesk.com", id: "TestUID2Token"))
extendedIds.insert(NimbusExtendedId(source: "tradedesk.com", uids: [.init(id: "TestUID2Token")]))
NimbusAdManager.extendedIds = extendedIds
} else {
if let extendedId = NimbusAdManager.extendedIds?.first(where: { $0.source == "tradedesk.com" }) {
Expand Down
Loading