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
19 changes: 11 additions & 8 deletions demo-ios-swift/demo-ios-swift/GAMBannerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ final class GAMBannerViewController: UIViewController {
@IBAction func loadBannerWithTargeting(_ sender: UIButton) {
do {
try OPTABLE!.targeting { [weak self] result in
switch result {
case let .success(optableTargeting):
print("[OptableSDK] ✅ Success on /targeting API call: \(optableTargeting)")
self?.loadBanner(optableTargeting)

case let .failure(error):
print("[OptableSDK] 🚫 Error on /targeting API call: \(error)")
self?.loadBanner()
// The completion handler is not called on the main thread, and ads must be loaded on it.
DispatchQueue.main.async {
switch result {
case let .success(optableTargeting):
print("[OptableSDK] ✅ Success on /targeting API call: \(optableTargeting)")
self?.loadBanner(optableTargeting)

case let .failure(error):
print("[OptableSDK] 🚫 Error on /targeting API call: \(error)")
self?.loadBanner()
}
}
}
} catch {
Expand Down
23 changes: 14 additions & 9 deletions demo-ios-swift/demo-ios-swift/PrebidBannerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ final class PrebidBannerViewController: UIViewController { // Outlets
@IBAction func loadBannerWithTargeting(_ sender: UIButton) {
do {
try OPTABLE!.targeting { [weak self] result in
switch result {
case let .success(optableTargeting):
print("[OptableSDK] ✅ Success on /targeting API call: \(optableTargeting)")
self?.loadBanner(optableTargeting)

case let .failure(error):
print("[OptableSDK] 🚫 Error on /targeting API call: \(error)")
self?.loadBanner()
// The completion handler is not called on the main thread, and ads must be loaded on it.
DispatchQueue.main.async {
switch result {
case let .success(optableTargeting):
print("[OptableSDK] ✅ Success on /targeting API call: \(optableTargeting)")
self?.loadBanner(optableTargeting)

case let .failure(error):
print("[OptableSDK] 🚫 Error on /targeting API call: \(error)")
self?.loadBanner()
}
}
}
} catch {
Expand Down Expand Up @@ -107,7 +110,9 @@ private extension PrebidBannerViewController {
pbmBannerAdUnit = BannerAdUnit(configId: PREBID_STORED_IMP, size: .init(width: 320, height: 50))
pbmBannerAdUnit.fetchDemand(adObject: adRequest) { [weak self] status in
print("[PrebidMobile]:fetchDemand(adObject:): \(status.name())")
self?.loadGAMAd(adRequest)
DispatchQueue.main.async {
self?.loadGAMAd(adRequest)
}
}
}

Expand Down
Loading