From 4426ab3a8008525e7a80a97225f29816d5aa26f5 Mon Sep 17 00:00:00 2001 From: Helium Service <103450738+helium-service@users.noreply.github.com> Date: Wed, 17 Jan 2024 09:50:02 -0800 Subject: [PATCH] Update Version to 4.2.4.0.0.1 (#3) * [AUTO-GENERATED] Update version to 4.2.4.0.0.1 * [AUTO-GENERATED] Update copyright headers * Fetch token as per HB-6918 * Make backwards compatible * Cleanup --------- Co-authored-by: runner Co-authored-by: Alex Rice --- CHANGELOG.md | 4 ++ ChartboostMediationAdapterBidMachine.podspec | 2 +- Source/BidMachineAdapter.swift | 45 ++++++++++++++++---- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0544ed..d7c4763 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,5 +3,9 @@ Note the first digit of every adapter version corresponds to the major version of the Chartboost Mediation SDK compatible with that adapter. Adapters are compatible with any Chartboost Mediation SDK version within that major version. +### 4.2.4.0.0.1 +- Call to fetch bidding token now includes placement format. +- This version of the adapter has been certified with BidMachine 2.4.0.0. + ### 4.2.4.0.0.0 - This version of the adapter has been certified with BidMachine 2.4.0.0. diff --git a/ChartboostMediationAdapterBidMachine.podspec b/ChartboostMediationAdapterBidMachine.podspec index e7dfe3e..8eb3d85 100644 --- a/ChartboostMediationAdapterBidMachine.podspec +++ b/ChartboostMediationAdapterBidMachine.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'ChartboostMediationAdapterBidMachine' - spec.version = '4.2.4.0.0.0' + spec.version = '4.2.4.0.0.1' spec.license = { :type => 'MIT', :file => 'LICENSE.md' } spec.homepage = 'https://github.com/ChartBoost/chartboost-mediation-ios-adapter-bidmachine' spec.authors = { 'Chartboost' => 'https://www.chartboost.com/' } diff --git a/Source/BidMachineAdapter.swift b/Source/BidMachineAdapter.swift index 68b6a0d..db2418b 100644 --- a/Source/BidMachineAdapter.swift +++ b/Source/BidMachineAdapter.swift @@ -7,6 +7,7 @@ import ChartboostMediationSDK import Foundation import UIKit import BidMachine +import BidMachineApiCore // Needed for the PlacementFormat type final class BidMachineAdapter: PartnerAdapter { private let SOURCE_ID_KEY = "source_id" @@ -17,7 +18,7 @@ final class BidMachineAdapter: PartnerAdapter { /// The version of the adapter. /// It should have either 5 or 6 digits separated by periods, where the first digit is Chartboost Mediation SDK's major version, the last digit is the adapter's build version, and intermediate digits are the partner SDK's version. /// Format: `.....` where `.` is optional. - let adapterVersion = "4.2.4.0.0.0" + let adapterVersion = "4.2.4.0.0.1" /// The partner's unique identifier. let partnerIdentifier = "bidmachine" @@ -72,14 +73,39 @@ final class BidMachineAdapter: PartnerAdapter { /// - parameter completion: Closure to be performed with the fetched info. func fetchBidderInformation(request: PreBidRequest, completion: @escaping ([String : String]?) -> Void) { log(.fetchBidderInfoStarted(request)) - guard let token = BidMachineSdk.shared.token else { - let error = error(.prebidFailureInvalidArgument, description: "No bidding token provided by BidMachine SDK") - log(.fetchBidderInfoFailed(request, error: error)) - completion(nil) - return + let placementFormat: BidMachineApiCore.PlacementFormat + switch request.format { + case .banner: + placementFormat = .banner + case .interstitial: + placementFormat = .interstitial + case .rewarded: + placementFormat = .rewarded + default: + // Not using the `.adaptiveBanner` or `.rewardedInterstitial` cases directly to maintain + // backward compatibility with Chartboost Mediation 4.0 + if request.format.rawValue == "adaptive_banner" { + placementFormat = .banner + } else if request.format.rawValue == "rewarded_interstitial" { + placementFormat = .interstitial + } else { + let error = error(.prebidFailureInvalidArgument, description: "Unsupported ad format") + log(.fetchBidderInfoFailed(request, error: error)) + completion(nil) + return + } + } + + BidMachineSdk.shared.token(with: placementFormat) { [self] token in + guard let token else { + let error = error(.prebidFailureInvalidArgument, description: "No bidding token provided by BidMachine SDK") + log(.fetchBidderInfoFailed(request, error: error)) + completion(nil) + return + } + log(.fetchBidderInfoSucceeded(request)) + completion(["token": token]) } - log(.fetchBidderInfoSucceeded(request)) - completion(["token": token]) } /// Indicates if GDPR applies or not and the user's GDPR consent status. @@ -142,7 +168,8 @@ final class BidMachineAdapter: PartnerAdapter { case .banner: return BidMachineAdapterBannerAd(adapter: self, request: request, delegate: delegate) default: - // Not using the `.adaptiveBanner` case directly to maintain backward compatibility with Chartboost Mediation 4.0 + // Not using the `.adaptiveBanner` or `.rewardedInterstitial cases directly to maintain + // backward compatibility with Chartboost Mediation 4.0 if request.format.rawValue == "adaptive_banner" { return BidMachineAdapterBannerAd(adapter: self, request: request, delegate: delegate) } else if request.format.rawValue == "rewarded_interstitial" {