Skip to content

Commit

Permalink
Stop using no longer available GADAdFormat.unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-barros committed Feb 7, 2024
1 parent 6473fe7 commit 5435292
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Source/GoogleBiddingAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ final class GoogleBiddingAdapter: PartnerAdapter {
gbRequest.register(sharedExtras)

// Convert from our internal AdFormat type to Google's ad format type
let gbAdFormat = googleAdFormat(from: request.format)

guard let gbAdFormat = googleAdFormat(from: request.format) else {
let error = error(.prebidFailureUnknown, description: "Failed to map ad format \(request.format) to GADAdFormat")
log(.fetchBidderInfoFailed(request, error: error))
completion(nil)
return
}

GADQueryInfo.createQueryInfo(with: gbRequest, adFormat: gbAdFormat) { queryInfo, error in
if let token = queryInfo?.query {
self.log(.fetchBidderInfoSucceeded(request))
Expand Down Expand Up @@ -248,7 +253,7 @@ final class GoogleBiddingAdapter: PartnerAdapter {
}
}

func googleAdFormat(from adFormat: AdFormat) -> GADAdFormat {
func googleAdFormat(from adFormat: AdFormat) -> GADAdFormat? {
switch adFormat {
case .banner:
return GADAdFormat.banner
Expand All @@ -257,7 +262,14 @@ final class GoogleBiddingAdapter: PartnerAdapter {
case .rewarded:
return GADAdFormat.rewarded
default:
return GADAdFormat.unknown
// Not using the `.rewardedInterstitial` or `.adaptive_banner` cases directly to maintain backward compatibility with Chartboost Mediation 4.0
if adFormat.rawValue == "rewarded_interstitial" {
return GADAdFormat.rewardedInterstitial
} else if adFormat.rawValue == "adaptive_banner" {
return GADAdFormat.banner
} else {
return nil
}
}
}
}

0 comments on commit 5435292

Please sign in to comment.