From 5c275780a8196b7239d2fc87c0f387c1d5cf7973 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 1 Nov 2023 12:10:44 -0500 Subject: [PATCH 01/27] Makes unregister function public. --- PrebidMobile/AdUnits/Native/NativeAd.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index 242098d98..31c37a748 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -182,7 +182,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { return true } - private func unregisterViewFromTracking() { + func unregisterViewFromTracking() { detachAllGestureRecognizers() viewForTracking = nil invalidateTimer(viewabilityTimer) From 0897cc59a8113511d2b898a6ada2a568a016819e Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 1 Nov 2023 13:28:16 -0500 Subject: [PATCH 02/27] checking for nil and invalidating timer but may have to dive deeper for deinit. --- PrebidMobile/AdUnits/Native/NativeAd.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index 31c37a748..19b7c2d54 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -36,7 +36,13 @@ public class NativeAd: NSObject, CacheExpiryDelegate { private var viewabilityTimer: Timer? private var viewabilityValue = 0 private var impressionHasBeenTracked = false - private weak var viewForTracking: UIView? + private weak var viewForTracking: UIView? { + didSet { + if (viewForTracking == nil) { + invalidateTimer(viewabilityTimer) + } + } + } //Click Handling private var gestureRecognizerRecords = [NativeAdGestureRecognizerRecord]() @@ -182,7 +188,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { return true } - func unregisterViewFromTracking() { + private func unregisterViewFromTracking() { detachAllGestureRecognizers() viewForTracking = nil invalidateTimer(viewabilityTimer) From e3b7521adc0bb780f06c149a3924f8264ab0d4b4 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 6 Dec 2023 11:53:36 -0600 Subject: [PATCH 03/27] Added in multiple places just need to figure out the merging / what to do if other parameters are there. --- PrebidMobile/AdUnits/AdUnit.swift | 10 ++++++++++ .../AdUnits/MultiformatAdUnit/PrebidAdUnit.swift | 1 + .../AdUnits/MultiformatAdUnit/PrebidRequest.swift | 7 +++++++ PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h | 1 + PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m | 3 +++ .../Prebid/PBMCore/AdUnitConfig.swift | 4 ++++ .../Prebid/PBMCore/PBMPrebidParameterBuilder.m | 1 + 7 files changed, 27 insertions(+) diff --git a/PrebidMobile/AdUnits/AdUnit.swift b/PrebidMobile/AdUnits/AdUnit.swift index b40f2aa9c..6ab5f8efb 100644 --- a/PrebidMobile/AdUnits/AdUnit.swift +++ b/PrebidMobile/AdUnits/AdUnit.swift @@ -387,6 +387,16 @@ public class AdUnit: NSObject, DispatcherDelegate { return adUnitConfig.gpid } + // MARK: ORTBObject + + public func setOrtbObject(_ ortbObject: [String : Any]?) { + adUnitConfig.ortbObject = ortbObject + } + + public func getOrtbObject() -> [String : Any]? { + return adUnitConfig.ortbObject + } + // MARK: - others /** diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift index 3098506f2..0be754a37 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift @@ -128,6 +128,7 @@ public class PrebidAdUnit: NSObject { } adUnit.adUnitConfig.gpid = request.gpid + adUnit.adUnitConfig.ortbObject = request.ortbObject adUnit.adUnitConfig.setExtData(request.getExtData()) adUnit.adUnitConfig.setExtKeywords(request.getExtKeywords()) diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift index ce43ed397..b6d88cd7c 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift @@ -28,6 +28,7 @@ public class PrebidRequest: NSObject { private(set) var isRewarded = false private(set) var gpid: String? + private(set) var ortbObject: [String: Any]? // MARK: - Private properties @@ -53,6 +54,12 @@ public class PrebidRequest: NSObject { self.gpid = gpid } + // MARK: ORTBObject + + public func setRequestOrtbObject(_ ortbObject: [String: Any]?) { + self.ortbObject = ortbObject + } + // MARK: - adunit ext data aka inventory data (imp[].ext.data) /** diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h index 92cccb132..8c9107ed9 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h @@ -112,6 +112,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) NSMutableDictionary *extData; @property (nonatomic, strong, nullable) NSString *extKeywords; @property (nonatomic, strong, nullable) NSString *extGPID; +@property (nonatomic, strong, nullable) NSMutableDictionary *extOrtbObject; - (instancetype)init; diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m index 6c6b06010..b93d2ba3b 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m @@ -98,6 +98,7 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona _extData = jsonDictionary[@"ext"][@"data"]; _extKeywords = jsonDictionary[@"ext"][@"keywords"]; _extGPID = jsonDictionary[@"ext"][@"gpid"]; + //_extOrtbObject = return self; } @@ -130,6 +131,8 @@ - (nonnull PBMJsonDictionary *)extDictionary { ret[@"gpid"] = self.extGPID; } + //what to do with self.extOrtbObject + return [ret pbmCopyWithoutEmptyVals]; } diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift index dae70398e..83b5ba693 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift @@ -79,6 +79,10 @@ public class AdUnitConfig: NSObject, NSCopying { } public var gpid: String? + + public var ortbObject: [String: Any]? + + public var WTF: String? // MARK: - Public Methods diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m index 7029a8fa7..4271d8ca8 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m @@ -178,6 +178,7 @@ - (void)buildBidRequest:(nonnull PBMORTBBidRequest *)bidRequest { nextImp.extPrebid.storedAuctionResponse = Prebid.shared.storedAuctionResponse; nextImp.extPrebid.isRewardedInventory = self.adConfiguration.adConfiguration.isOptIn; nextImp.extGPID = self.adConfiguration.gpid; + nextImp.extOrtbObject = self.adConfiguration.ortbObject; if ([self.adConfiguration getExtData].count > 0) { nextImp.extData = [self.adConfiguration getExtData].mutableCopy; From dad6d277127f5772e10240d2ad34c745cc3f3165 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Mon, 11 Dec 2023 11:14:32 -0600 Subject: [PATCH 04/27] Loading and sending arbitrary values done. --- PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m index b93d2ba3b..c5b651085 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m @@ -98,7 +98,8 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona _extData = jsonDictionary[@"ext"][@"data"]; _extKeywords = jsonDictionary[@"ext"][@"keywords"]; _extGPID = jsonDictionary[@"ext"][@"gpid"]; - //_extOrtbObject = + //take all key values stored in ext because they will be filtered before sending + _extOrtbObject = jsonDictionary[@"ext"]; return self; } @@ -131,8 +132,12 @@ - (nonnull PBMJsonDictionary *)extDictionary { ret[@"gpid"] = self.extGPID; } - //what to do with self.extOrtbObject - + //loop through extra fields and add arbitrary ones but don't override the previously provided ones + //leave this loop at the end (or beginning) of this method so we don't duplicate fields and override provided ones + for (id key in self.extOrtbObject) + if ([ret objectForKey:key] == nil) + [ret setObject:[self.extOrtbObject objectForKey:key] forKey: key]; + return [ret pbmCopyWithoutEmptyVals]; } From c85bf653a85ec31a29368725c8e81b290e8a59bb Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Tue, 12 Dec 2023 10:57:35 -0600 Subject: [PATCH 05/27] Finished writing tests. --- .../AdUnitTests/PrebidAdUnitTests.swift | 36 +++++++++++++++++++ .../Tests/PBMORTBAbstractTest.swift | 11 ++++++ .../PrebidParameterBuilderTest.swift | 15 ++++++++ 3 files changed, 62 insertions(+) diff --git a/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift b/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift index 168240bec..5d3ca0dcb 100644 --- a/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift +++ b/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift @@ -402,4 +402,40 @@ class PrebidAdUnitTests: XCTestCase { waitForExpectations(timeout: 5, handler: nil) } + + func testAdUnitConfiguration_arbitraryParams() { + let expectation = expectation(description: "\(#function)") + expectation.expectedFulfillmentCount = 2 + + let gpid = "/12345/home_screen#identifier" + let arbitraryParams = ["param1": "param1", "param2": 1, "param3": true] as [String : Any] + var adUnit = PrebidAdUnit(configId: "test-config-id") + + let request = PrebidRequest(bannerParameters: BannerParameters()) + request.setGPID(gpid) + request.setRequestOrtbObject(arbitraryParams) + + // fetchDemand(request:completion) + adUnit.fetchDemand(request: request) { _ in + expectation.fulfill() + XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) + XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param1"] as? String, "param1") + XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param2"] as? Int, 1) + XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param3"] as? Bool, true) + } + + let testObject: AnyObject = () as AnyObject + adUnit = PrebidAdUnit(configId: "test-config-id") + + // fetchDemand(adObject:request:completion) + adUnit.fetchDemand(adObject: testObject, request: request) { _ in + expectation.fulfill() + XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) + XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param1"] as? String, "param1") + XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param2"] as? Int, 1) + XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param3"] as? Bool, true) + } + + waitForExpectations(timeout: 5, handler: nil) + } } diff --git a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift index 126b33a5c..dda2a7722 100644 --- a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift @@ -306,6 +306,17 @@ class PBMORTBAbstractTest : XCTestCase { codeAndDecode(abstract: imp, expectedString: "{\"clickbrowser\":0,\"ext\":{\"dlp\":1,\"gpid\":\"\\/12345\\/home_screen#identifier\"},\"instl\":0,\"secure\":0}") } + func testImpExtArbitraryORTBParams() { + let gpid = "/12345/home_screen#identifier" + + let imp = PBMORTBImp() + imp.extGPID = gpid + let swiftDictionary = ["param1": "param1", "param2": 1, "param3": true] as [String : Any] + imp.extOrtbObject = NSMutableDictionary(dictionary: swiftDictionary) + + codeAndDecode(abstract: imp, expectedString: "{\"clickbrowser\":0,\"ext\":{\"dlp\":1,\"gpid\":\"\\/12345\\/home_screen#identifier\",\"param1\":\"param1\",\"param2\":1,\"param3\":true},\"instl\":0,\"secure\":0}") + } + func testBannerToJsonString() { let pbmORTBBanner = PBMORTBBanner() pbmORTBBanner.pos = 1 //Above the fold diff --git a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift index 454abbbe1..8c093de27 100644 --- a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift @@ -784,6 +784,21 @@ class PrebidParameterBuilderTest: XCTestCase { XCTAssertEqual(imp.extGPID, gpid) } } + + func testArbitraryORTBParams() { + let gpid = "/12345/home_screen#identifier" + let adUnit = AdUnit(configId: "test", size: CGSize.zero, adFormats: [.banner]) + adUnit.setGPID(gpid) + adUnit.setOrtbObject(["param1": "param1", "param2": 1, "param3": true] as [String : Any]) + + let bidRequest = buildBidRequest(with: adUnit.adUnitConfig) + for imp in bidRequest.imp { + XCTAssertEqual(imp.extGPID, gpid) + XCTAssertEqual((imp.extOrtbObject)?["param1"] as? String, "param1") + XCTAssertEqual((imp.extOrtbObject)?["param2"] as? Int, 1) + XCTAssertEqual((imp.extOrtbObject)?["param3"] as? Bool, true) + } + } // MARK: - Helpers From c3c62be00432daf9414f7758173a663b274c8902 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 13 Dec 2023 12:01:39 -0600 Subject: [PATCH 06/27] Update GAM version --- InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj | 6 +++--- .../ConfigurationAndTargeting/PrebidGAMVersionChecker.swift | 2 +- tools/PrebidValidator/Dr.Prebid.xcodeproj/project.pbxproj | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj b/InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj index 429ef5d97..202ed7c4e 100644 --- a/InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj +++ b/InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj @@ -1302,7 +1302,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-InternalTestApp-Skadn/Pods-InternalTestApp-Skadn-resources.sh", - "${PODS_ROOT}/AppLovinSDK/applovin-ios-sdk-11.11.3/AppLovinSDKResources.bundle", + "${PODS_ROOT}/AppLovinSDK/applovin-ios-sdk-12.1.0/AppLovinSDKResources.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( @@ -1320,7 +1320,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-InternalTestApp/Pods-InternalTestApp-resources.sh", - "${PODS_ROOT}/AppLovinSDK/applovin-ios-sdk-11.11.3/AppLovinSDKResources.bundle", + "${PODS_ROOT}/AppLovinSDK/applovin-ios-sdk-12.1.0/AppLovinSDKResources.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( @@ -1458,7 +1458,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-InternalTestAppTests/Pods-InternalTestAppTests-resources.sh", - "${PODS_ROOT}/AppLovinSDK/applovin-ios-sdk-11.11.3/AppLovinSDKResources.bundle", + "${PODS_ROOT}/AppLovinSDK/applovin-ios-sdk-12.1.0/AppLovinSDKResources.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( diff --git a/PrebidMobile/ConfigurationAndTargeting/PrebidGAMVersionChecker.swift b/PrebidMobile/ConfigurationAndTargeting/PrebidGAMVersionChecker.swift index 73001838d..c4b3a92ab 100644 --- a/PrebidMobile/ConfigurationAndTargeting/PrebidGAMVersionChecker.swift +++ b/PrebidMobile/ConfigurationAndTargeting/PrebidGAMVersionChecker.swift @@ -18,7 +18,7 @@ import Foundation class PrebidGAMVersionChecker { var latestTestedGMAVersion: (Int, Int, Int) { - (10, 12, 0) + (10, 14, 0) } var currentGMAVersion: (Int, Int, Int)? diff --git a/tools/PrebidValidator/Dr.Prebid.xcodeproj/project.pbxproj b/tools/PrebidValidator/Dr.Prebid.xcodeproj/project.pbxproj index 9b65a6f33..58327f47c 100644 --- a/tools/PrebidValidator/Dr.Prebid.xcodeproj/project.pbxproj +++ b/tools/PrebidValidator/Dr.Prebid.xcodeproj/project.pbxproj @@ -647,7 +647,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Dr.Prebid/Pods-Dr.Prebid-resources.sh", - "${PODS_ROOT}/AppLovinSDK/applovin-ios-sdk-11.11.3/AppLovinSDKResources.bundle", + "${PODS_ROOT}/AppLovinSDK/applovin-ios-sdk-12.1.0/AppLovinSDKResources.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( From 65fa06b4c84f5473cf8efe6f4ca82940228ae55d Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Fri, 15 Dec 2023 12:05:36 -0600 Subject: [PATCH 07/27] whoops, removing this. --- .../PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift index 83b5ba693..4b67f92c0 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift @@ -82,8 +82,6 @@ public class AdUnitConfig: NSObject, NSCopying { public var ortbObject: [String: Any]? - public var WTF: String? - // MARK: - Public Methods public convenience init(configId: String) { From 8ec26b37c032853f0abe566838f1d79442205d92 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 3 Jan 2024 13:35:03 -0600 Subject: [PATCH 08/27] Finished imp and imp.ext levels. Need to do global ext. --- Podfile.lock | 54 ++++++++++--------- PrebidMobile/AdUnits/AdUnit.swift | 20 +++++-- .../MultiformatAdUnit/PrebidAdUnit.swift | 4 +- .../MultiformatAdUnit/PrebidRequest.swift | 21 ++++++-- .../PrebidMobileRendering/ORTB/PBMORTBImp.h | 3 +- .../PrebidMobileRendering/ORTB/PBMORTBImp.m | 16 ++++-- .../Prebid/PBMCore/AdUnitConfig.swift | 4 +- .../PBMCore/ORTB/Prebid/PBMORTBBidExt.h | 3 ++ .../PBMCore/ORTB/Prebid/PBMORTBBidExt.m | 2 + .../PBMCore/PBMPrebidParameterBuilder.m | 3 +- .../AdUnitTests/PrebidAdUnitTests.swift | 21 +++++--- .../Tests/PBMORTBAbstractTest.swift | 6 +-- .../PrebidParameterBuilderTest.swift | 12 +++-- 13 files changed, 110 insertions(+), 59 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 200062d7c..d363babbe 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,57 +1,59 @@ PODS: - Alamofire (4.9.1) - - AppLovinSDK (11.11.3) + - AppLovinSDK (12.1.0) - Eureka (5.4.0) - - Google-Mobile-Ads-SDK (10.12.0): + - Google-Mobile-Ads-SDK (10.14.0): - GoogleAppMeasurement (< 11.0, >= 7.0) - GoogleUserMessagingPlatform (>= 1.1) - GoogleAds-IMA-iOS-SDK (3.19.2) - - GoogleAppMeasurement (10.16.0): - - GoogleAppMeasurement/AdIdSupport (= 10.16.0) + - GoogleAppMeasurement (10.19.0): + - GoogleAppMeasurement/AdIdSupport (= 10.19.0) - GoogleUtilities/AppDelegateSwizzler (~> 7.11) - GoogleUtilities/MethodSwizzler (~> 7.11) - GoogleUtilities/Network (~> 7.11) - "GoogleUtilities/NSData+zlib (~> 7.11)" - nanopb (< 2.30910.0, >= 2.30908.0) - - GoogleAppMeasurement/AdIdSupport (10.16.0): - - GoogleAppMeasurement/WithoutAdIdSupport (= 10.16.0) + - GoogleAppMeasurement/AdIdSupport (10.19.0): + - GoogleAppMeasurement/WithoutAdIdSupport (= 10.19.0) - GoogleUtilities/AppDelegateSwizzler (~> 7.11) - GoogleUtilities/MethodSwizzler (~> 7.11) - GoogleUtilities/Network (~> 7.11) - "GoogleUtilities/NSData+zlib (~> 7.11)" - nanopb (< 2.30910.0, >= 2.30908.0) - - GoogleAppMeasurement/WithoutAdIdSupport (10.16.0): + - GoogleAppMeasurement/WithoutAdIdSupport (10.19.0): - GoogleUtilities/AppDelegateSwizzler (~> 7.11) - GoogleUtilities/MethodSwizzler (~> 7.11) - GoogleUtilities/Network (~> 7.11) - "GoogleUtilities/NSData+zlib (~> 7.11)" - nanopb (< 2.30910.0, >= 2.30908.0) - GoogleUserMessagingPlatform (2.1.0) - - GoogleUtilities/AppDelegateSwizzler (7.11.5): + - GoogleUtilities/AppDelegateSwizzler (7.12.0): - GoogleUtilities/Environment - GoogleUtilities/Logger - GoogleUtilities/Network - - GoogleUtilities/Environment (7.11.5): + - GoogleUtilities/Environment (7.12.0): - PromisesObjC (< 3.0, >= 1.2) - - GoogleUtilities/Logger (7.11.5): + - GoogleUtilities/Logger (7.12.0): - GoogleUtilities/Environment - - GoogleUtilities/MethodSwizzler (7.11.5): + - GoogleUtilities/MethodSwizzler (7.12.0): - GoogleUtilities/Logger - - GoogleUtilities/Network (7.11.5): + - GoogleUtilities/Network (7.12.0): - GoogleUtilities/Logger - "GoogleUtilities/NSData+zlib" - GoogleUtilities/Reachability - - "GoogleUtilities/NSData+zlib (7.11.5)" - - GoogleUtilities/Reachability (7.11.5): + - "GoogleUtilities/NSData+zlib (7.12.0)" + - GoogleUtilities/Reachability (7.12.0): - GoogleUtilities/Logger - - nanopb (2.30909.0): - - nanopb/decode (= 2.30909.0) - - nanopb/encode (= 2.30909.0) - - nanopb/decode (2.30909.0) - - nanopb/encode (2.30909.0) + - nanopb (2.30909.1): + - nanopb/decode (= 2.30909.1) + - nanopb/encode (= 2.30909.1) + - nanopb/decode (2.30909.1) + - nanopb/encode (2.30909.1) - PromisesObjC (2.3.1) - RxSwift (6.6.0) - - SVProgressHUD (2.2.5) + - SVProgressHUD (2.3.1): + - SVProgressHUD/Core (= 2.3.1) + - SVProgressHUD/Core (2.3.1) DEPENDENCIES: - Alamofire (= 4.9.1) @@ -79,17 +81,17 @@ SPEC REPOS: SPEC CHECKSUMS: Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18 - AppLovinSDK: 623ef78363c0dd2c3ff5446cde37e4920a96b7e0 + AppLovinSDK: 179d509c258e01a3a77eb8416f0ba843a12ed322 Eureka: fadaa9fa3d6e402d3c60f78f24edf3d7bafc9c29 - Google-Mobile-Ads-SDK: 976fdf273815674eed30b8aafffedb3c25b055e4 + Google-Mobile-Ads-SDK: 8f67a72f88d057335b1ac3f501e2b68ad054116e GoogleAds-IMA-iOS-SDK: 0e817c05ab26f1b9285c80f4a75e1350a916d50b - GoogleAppMeasurement: 079d7632810e9d9704a99932547ba1554acc4342 + GoogleAppMeasurement: 68afe759316673c6554dac35a0c7ae8f5d6cb4ed GoogleUserMessagingPlatform: dce302b8f1b84d6e945812ee7a15c3f65a102cbf - GoogleUtilities: 13e2c67ede716b8741c7989e26893d151b2b2084 - nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 + GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34 + nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5 PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 RxSwift: a4b44f7d24599f674deebd1818eab82e58410632 - SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6 + SVProgressHUD: 4837c74bdfe2e51e8821c397825996a8d7de6e22 PODFILE CHECKSUM: bae4436ed691a1d2217fde386d8881d6e7e06963 diff --git a/PrebidMobile/AdUnits/AdUnit.swift b/PrebidMobile/AdUnits/AdUnit.swift index 6ab5f8efb..d19744999 100644 --- a/PrebidMobile/AdUnits/AdUnit.swift +++ b/PrebidMobile/AdUnits/AdUnit.swift @@ -387,14 +387,24 @@ public class AdUnit: NSObject, DispatcherDelegate { return adUnitConfig.gpid } - // MARK: ORTBObject + // MARK: IMP ORTBObject + public func setImpORTBObject(_ ortbObject: [String : Any]?) { + adUnitConfig.impORTBObject = ortbObject + } + + public func getImpORTBObject() -> [String : Any]? { + return adUnitConfig.impORTBObject + } + + + // MARK: IMP EXT ORTBObject - public func setOrtbObject(_ ortbObject: [String : Any]?) { - adUnitConfig.ortbObject = ortbObject + public func setImpExtORTBObject(_ ortbObject: [String : Any]?) { + adUnitConfig.impExtORTBObject = ortbObject } - public func getOrtbObject() -> [String : Any]? { - return adUnitConfig.ortbObject + public func getImpExtORTBObject() -> [String : Any]? { + return adUnitConfig.impExtORTBObject } // MARK: - others diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift index 0be754a37..4d4f51cd0 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift @@ -128,8 +128,8 @@ public class PrebidAdUnit: NSObject { } adUnit.adUnitConfig.gpid = request.gpid - adUnit.adUnitConfig.ortbObject = request.ortbObject - + adUnit.adUnitConfig.impORTBObject = request.impORTBObject + adUnit.adUnitConfig.impExtORTBObject = request.impExtORTBObject adUnit.adUnitConfig.setExtData(request.getExtData()) adUnit.adUnitConfig.setExtKeywords(request.getExtKeywords()) adUnit.adUnitConfig.setAppContent(request.getAppContent()) diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift index b6d88cd7c..c83b09a71 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift @@ -28,7 +28,8 @@ public class PrebidRequest: NSObject { private(set) var isRewarded = false private(set) var gpid: String? - private(set) var ortbObject: [String: Any]? + private(set) var impORTBObject: [String: Any]? + private(set) var impExtORTBObject: [String: Any]? // MARK: - Private properties @@ -54,10 +55,22 @@ public class PrebidRequest: NSObject { self.gpid = gpid } - // MARK: ORTBObject + // MARK: IMP ORTBObject - public func setRequestOrtbObject(_ ortbObject: [String: Any]?) { - self.ortbObject = ortbObject + /** + For Arbitrary parameters in the imp level + */ + public func setRequestImpOrtbObject(_ ortbObject: [String: Any]?) { + self.impORTBObject = ortbObject + } + + // MARK: IMP EXT ORTBObject + + /** + For Arbitrary parameters in the ext level under imp + */ + public func setRequestImpExtOrtbObject(_ ortbObject: [String: Any]?) { + self.impExtORTBObject = ortbObject } // MARK: - adunit ext data aka inventory data (imp[].ext.data) diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h index 8c9107ed9..93c05c35c 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h @@ -112,7 +112,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) NSMutableDictionary *extData; @property (nonatomic, strong, nullable) NSString *extKeywords; @property (nonatomic, strong, nullable) NSString *extGPID; -@property (nonatomic, strong, nullable) NSMutableDictionary *extOrtbObject; +@property (nonatomic, strong, nullable) NSDictionary *impExtORTBObject; +@property (nonatomic, strong, nullable) NSDictionary *impORTBObject; - (instancetype)init; diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m index c5b651085..62a2475f1 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m @@ -58,6 +58,12 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary { ret[@"ext"] = [[self extDictionary] nullIfEmpty]; + //loop through extra fields and add arbitrary ones but don't override the previously provided ones + //leave this loop at the end of this method so we don't duplicate fields and override provided ones + for (id key in self.impORTBObject) + if ([ret objectForKey:key] == nil) + [ret setObject:[self.impORTBObject objectForKey:key] forKey: key]; + ret = [ret pbmCopyWithoutEmptyVals]; return ret; @@ -99,7 +105,9 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona _extKeywords = jsonDictionary[@"ext"][@"keywords"]; _extGPID = jsonDictionary[@"ext"][@"gpid"]; //take all key values stored in ext because they will be filtered before sending - _extOrtbObject = jsonDictionary[@"ext"]; + _impExtORTBObject = jsonDictionary[@"ext"]; + + _impORTBObject = jsonDictionary; return self; } @@ -133,10 +141,10 @@ - (nonnull PBMJsonDictionary *)extDictionary { } //loop through extra fields and add arbitrary ones but don't override the previously provided ones - //leave this loop at the end (or beginning) of this method so we don't duplicate fields and override provided ones - for (id key in self.extOrtbObject) + //leave this loop at the end of this method so we don't duplicate fields and override provided ones + for (id key in self.impExtORTBObject) if ([ret objectForKey:key] == nil) - [ret setObject:[self.extOrtbObject objectForKey:key] forKey: key]; + [ret setObject:[self.impExtORTBObject objectForKey:key] forKey: key]; return [ret pbmCopyWithoutEmptyVals]; } diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift index 4b67f92c0..54456a1d2 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift @@ -80,7 +80,9 @@ public class AdUnitConfig: NSObject, NSCopying { public var gpid: String? - public var ortbObject: [String: Any]? + public var impExtORTBObject: [String: Any]? + + public var impORTBObject: [String: Any]? // MARK: - Public Methods diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h index 15d5ef756..053055cbb 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h @@ -31,6 +31,9 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) PBMORTBBidExtSkadn *skadn; +@property (nonatomic, copy, nullable) NSMutableDictionary *ortbObject; + + // This part is dedicating to test server-side ad configurations. // Need to be removed when ext.prebid.passthrough will be available. #if DEBUG diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m index ccc2bedb5..04afe1b25 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m @@ -80,6 +80,8 @@ - (PBMJsonDictionary *)toJsonDictionary { } #endif + + [ret pbmRemoveEmptyVals]; return ret; diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m index 4271d8ca8..33d862ca4 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m @@ -178,7 +178,8 @@ - (void)buildBidRequest:(nonnull PBMORTBBidRequest *)bidRequest { nextImp.extPrebid.storedAuctionResponse = Prebid.shared.storedAuctionResponse; nextImp.extPrebid.isRewardedInventory = self.adConfiguration.adConfiguration.isOptIn; nextImp.extGPID = self.adConfiguration.gpid; - nextImp.extOrtbObject = self.adConfiguration.ortbObject; + nextImp.impExtORTBObject = self.adConfiguration.impExtORTBObject; + nextImp.impORTBObject = self.adConfiguration.impORTBObject; if ([self.adConfiguration getExtData].count > 0) { nextImp.extData = [self.adConfiguration getExtData].mutableCopy; diff --git a/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift b/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift index 5d3ca0dcb..b9a195f89 100644 --- a/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift +++ b/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift @@ -408,20 +408,25 @@ class PrebidAdUnitTests: XCTestCase { expectation.expectedFulfillmentCount = 2 let gpid = "/12345/home_screen#identifier" - let arbitraryParams = ["param1": "param1", "param2": 1, "param3": true] as [String : Any] + let impArbitraryParams = ["impparam1": "impparam1", "impparam2": 2, "impparam3": false] as [String : Any] + let extArbitraryParams = ["param1": "param1", "param2": 1, "param3": true] as [String : Any] var adUnit = PrebidAdUnit(configId: "test-config-id") let request = PrebidRequest(bannerParameters: BannerParameters()) request.setGPID(gpid) - request.setRequestOrtbObject(arbitraryParams) + request.setRequestImpOrtbObject(impArbitraryParams) + request.setRequestImpExtOrtbObject(extArbitraryParams) // fetchDemand(request:completion) adUnit.fetchDemand(request: request) { _ in expectation.fulfill() XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) - XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param1"] as? String, "param1") - XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param2"] as? Int, 1) - XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param3"] as? Bool, true) + XCTAssertEqual((adUnit.getConfiguration().impORTBObject)?["impparam1"] as? String, "impparam1") + XCTAssertEqual((adUnit.getConfiguration().impORTBObject)?["impparam2"] as? Int, 2) + XCTAssertEqual((adUnit.getConfiguration().impORTBObject)?["impparam3"] as? Bool, false) + XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param1"] as? String, "param1") + XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param2"] as? Int, 1) + XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param3"] as? Bool, true) } let testObject: AnyObject = () as AnyObject @@ -431,9 +436,9 @@ class PrebidAdUnitTests: XCTestCase { adUnit.fetchDemand(adObject: testObject, request: request) { _ in expectation.fulfill() XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) - XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param1"] as? String, "param1") - XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param2"] as? Int, 1) - XCTAssertEqual((adUnit.getConfiguration().ortbObject)?["param3"] as? Bool, true) + XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param1"] as? String, "param1") + XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param2"] as? Int, 1) + XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param3"] as? Bool, true) } waitForExpectations(timeout: 5, handler: nil) diff --git a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift index dda2a7722..6b062793b 100644 --- a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift @@ -311,10 +311,10 @@ class PBMORTBAbstractTest : XCTestCase { let imp = PBMORTBImp() imp.extGPID = gpid - let swiftDictionary = ["param1": "param1", "param2": 1, "param3": true] as [String : Any] - imp.extOrtbObject = NSMutableDictionary(dictionary: swiftDictionary) + imp.impORTBObject = ["impparam1": "impparam1", "impparam2": 2, "impparam3": false, "secure": 1] as [String : Any] + imp.impExtORTBObject = ["param1": "param1", "param2": 1, "param3": true] as [String : Any] - codeAndDecode(abstract: imp, expectedString: "{\"clickbrowser\":0,\"ext\":{\"dlp\":1,\"gpid\":\"\\/12345\\/home_screen#identifier\",\"param1\":\"param1\",\"param2\":1,\"param3\":true},\"instl\":0,\"secure\":0}") + codeAndDecode(abstract: imp, expectedString: "{\"clickbrowser\":0,\"ext\":{\"dlp\":1,\"gpid\":\"\\/12345\\/home_screen#identifier\",\"param1\":\"param1\",\"param2\":1,\"param3\":true},\"impparam1\":\"impparam1\",\"impparam2\":2,\"impparam3\":false,\"instl\":0,\"secure\":0}") } func testBannerToJsonString() { diff --git a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift index 8c093de27..a24d62d65 100644 --- a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift @@ -789,14 +789,18 @@ class PrebidParameterBuilderTest: XCTestCase { let gpid = "/12345/home_screen#identifier" let adUnit = AdUnit(configId: "test", size: CGSize.zero, adFormats: [.banner]) adUnit.setGPID(gpid) - adUnit.setOrtbObject(["param1": "param1", "param2": 1, "param3": true] as [String : Any]) + adUnit.setImpORTBObject(["impLevel1": "param1", "impLevel2": 1, "impLevel3": true] as [String : Any]) + adUnit.setImpExtORTBObject(["param1": "param1", "param2": 1, "param3": true] as [String : Any]) let bidRequest = buildBidRequest(with: adUnit.adUnitConfig) for imp in bidRequest.imp { XCTAssertEqual(imp.extGPID, gpid) - XCTAssertEqual((imp.extOrtbObject)?["param1"] as? String, "param1") - XCTAssertEqual((imp.extOrtbObject)?["param2"] as? Int, 1) - XCTAssertEqual((imp.extOrtbObject)?["param3"] as? Bool, true) + XCTAssertEqual((imp.impORTBObject)?["impLevel1"] as? String, "param1") + XCTAssertEqual((imp.impORTBObject)?["impLevel2"] as? Int, 1) + XCTAssertEqual((imp.impORTBObject)?["impLevel3"] as? Bool, true) + XCTAssertEqual((imp.impExtORTBObject)?["param1"] as? String, "param1") + XCTAssertEqual((imp.impExtORTBObject)?["param2"] as? Int, 1) + XCTAssertEqual((imp.impExtORTBObject)?["param3"] as? Bool, true) } } From 2f3f6ba943a9600beebde6cd0068dbf8062b066b Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 3 Jan 2024 13:39:05 -0600 Subject: [PATCH 09/27] Support all the way through. --- .../Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h | 2 +- .../Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h index 053055cbb..58267a7d3 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h @@ -31,7 +31,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) PBMORTBBidExtSkadn *skadn; -@property (nonatomic, copy, nullable) NSMutableDictionary *ortbObject; +@property (nonatomic, copy, nullable) NSDictionary *ortbObject; // This part is dedicating to test server-side ad configurations. diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m index 04afe1b25..b6c3232c1 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m @@ -42,6 +42,8 @@ - (instancetype)initWithJsonDictionary:(PBMJsonDictionary *)jsonDictionary { _skadn = [[PBMORTBBidExtSkadn alloc] initWithJsonDictionary:skadnDict]; } + _ortbObject = jsonDictionary; + #if DEBUG NSArray * const passthroughDics = jsonDictionary[@"passthrough"]; _passthrough = nil; @@ -69,6 +71,12 @@ - (PBMJsonDictionary *)toJsonDictionary { ret[@"prebid"] = [self.prebid toJsonDictionary]; ret[@"skadn"] = [self.skadn toJsonDictionary]; + //loop through extra fields and add arbitrary ones but don't override the previously provided ones + //leave this loop at the end of this method so we don't duplicate fields and override provided ones + for (id key in self.ortbObject) + if ([ret objectForKey:key] == nil) + [ret setObject:[self.ortbObject objectForKey:key] forKey: key]; + #if DEBUG NSMutableArray * const passthroughDicArr = [[NSMutableArray alloc] initWithCapacity:self.passthrough.count]; for(PBMORTBExtPrebidPassthrough *nextPassthrough in self.passthrough) { From a642064b6b5d42ed99ff7962607483b4ba5e9760 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Thu, 4 Jan 2024 08:57:11 -0600 Subject: [PATCH 10/27] I believe this covers the implementation for the global ext object in bidrequest --- .../PrebidParameterBuilderTest.swift | 12 ++++++++++++ .../RenderingTests/Tests/Prebid/PBMORTBTest.swift | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift index a24d62d65..f08141d5b 100644 --- a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift @@ -785,6 +785,18 @@ class PrebidParameterBuilderTest: XCTestCase { } } + func testGlobalArbitraryORTBParams() { + let gpid = "/12345/home_screen#identifier" + let adUnit = AdUnit(configId: "test", size: CGSize.zero, adFormats: [.banner]) + adUnit.setGPID(gpid) + + let bidRequest = buildBidRequest(with: adUnit.adUnitConfig) + + for imp in bidRequest.imp { + XCTAssertEqual(imp.extGPID, gpid) + } + } + func testArbitraryORTBParams() { let gpid = "/12345/home_screen#identifier" let adUnit = AdUnit(configId: "test", size: CGSize.zero, adFormats: [.banner]) diff --git a/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift b/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift index 432753fdf..e4b93cce6 100644 --- a/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift @@ -166,7 +166,7 @@ class PBMORTBTest: XCTestCase { "hb_cache_id": "32541b8f-5d49-446d-ae26-18629273a6fe", ] prebid.type = "banner" - + ext.ortbObject = ["arbitraryParam1": "param1", "arbitraryParam2": 1, "arbitraryParam3": true] as [String : Any] ext.prebid = prebid ext.bidder = [ "ad_ox_cats": [ @@ -183,7 +183,7 @@ class PBMORTBTest: XCTestCase { "next_highest_bid_price": 0.099, ] - codeAndDecode(abstract: ext, expectedString: "{\"bidder\":{\"ad_ox_cats\":[2],\"agency_id\":\"agency_10\",\"brand_id\":\"brand_10\",\"buyer_id\":\"buyer_10\",\"matching_ad_id\":{\"campaign_id\":1,\"creative_id\":3,\"placement_id\":2},\"next_highest_bid_price\":0.099000000000000005},\"prebid\":{\"cache\":{\"bids\":{\"cacheId\":\"32541b8f-5d49-446d-ae26-18629273a6fe\",\"url\":\"prebid.devint.openx.net\\/cache?uuid=32541b8f-5d49-446d-ae26-18629273a6fe\"},\"key\":\"kkk\",\"url\":\"some\\/url\"},\"targeting\":{\"hb_bidder\":\"openx\",\"hb_cache_host\":\"prebid.devint.openx.net\",\"hb_cache_id\":\"32541b8f-5d49-446d-ae26-18629273a6fe\",\"hb_cache_path\":\"\\/cache\"},\"type\":\"banner\"}}") + codeAndDecode(abstract: ext, expectedString: "{\"arbitraryParam1\":\"param1\",\"arbitraryParam2\":1,\"arbitraryParam3\":true,\"bidder\":{\"ad_ox_cats\":[2],\"agency_id\":\"agency_10\",\"brand_id\":\"brand_10\",\"buyer_id\":\"buyer_10\",\"matching_ad_id\":{\"campaign_id\":1,\"creative_id\":3,\"placement_id\":2},\"next_highest_bid_price\":0.099000000000000005},\"prebid\":{\"cache\":{\"bids\":{\"cacheId\":\"32541b8f-5d49-446d-ae26-18629273a6fe\",\"url\":\"prebid.devint.openx.net\\/cache?uuid=32541b8f-5d49-446d-ae26-18629273a6fe\"},\"key\":\"kkk\",\"url\":\"some\\/url\"},\"targeting\":{\"hb_bidder\":\"openx\",\"hb_cache_host\":\"prebid.devint.openx.net\",\"hb_cache_id\":\"32541b8f-5d49-446d-ae26-18629273a6fe\",\"hb_cache_path\":\"\\/cache\"},\"type\":\"banner\"}}") } func testBidResponseExt() { From 86cc5df87e957b4f8a0f93f90c3391403fd21672 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Thu, 4 Jan 2024 12:11:29 -0600 Subject: [PATCH 11/27] Added globally. --- PrebidMobile/AdUnits/AdUnit.swift | 20 +++------ .../MultiformatAdUnit/PrebidAdUnit.swift | 2 - .../MultiformatAdUnit/PrebidRequest.swift | 22 +--------- .../ORTB/PBMORTBBidRequest.h | 3 ++ .../ORTB/PBMORTBBidRequest.m | 5 +++ .../PrebidMobileRendering/ORTB/PBMORTBImp.h | 2 - .../PrebidMobileRendering/ORTB/PBMORTBImp.m | 15 +------ .../Prebid/PBMCore/AdUnitConfig.swift | 4 +- .../PBMCore/ORTB/Prebid/PBMORTBBidExt.h | 3 -- .../PBMCore/ORTB/Prebid/PBMORTBBidExt.m | 10 +---- .../PBMCore/PBMPrebidParameterBuilder.m | 3 +- .../AdUnitTests/PrebidAdUnitTests.swift | 41 ------------------- .../Tests/PBMORTBAbstractTest.swift | 16 +++----- .../PrebidParameterBuilderTest.swift | 19 --------- .../Tests/Prebid/PBMORTBTest.swift | 3 +- 15 files changed, 24 insertions(+), 144 deletions(-) diff --git a/PrebidMobile/AdUnits/AdUnit.swift b/PrebidMobile/AdUnits/AdUnit.swift index d19744999..52f33a830 100644 --- a/PrebidMobile/AdUnits/AdUnit.swift +++ b/PrebidMobile/AdUnits/AdUnit.swift @@ -387,24 +387,14 @@ public class AdUnit: NSObject, DispatcherDelegate { return adUnitConfig.gpid } - // MARK: IMP ORTBObject - public func setImpORTBObject(_ ortbObject: [String : Any]?) { - adUnitConfig.impORTBObject = ortbObject - } - - public func getImpORTBObject() -> [String : Any]? { - return adUnitConfig.impORTBObject - } - - - // MARK: IMP EXT ORTBObject + // MARK: ORTBObject - public func setImpExtORTBObject(_ ortbObject: [String : Any]?) { - adUnitConfig.impExtORTBObject = ortbObject + public func setOrtbObject(_ ortbObject: [String: Any]?) { + adUnitConfig.ortbObject = ortbObject } - public func getImpExtORTBObject() -> [String : Any]? { - return adUnitConfig.impExtORTBObject + public func getOrtbObject() -> [String: Any]? { + return adUnitConfig.ortbObject } // MARK: - others diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift index 4d4f51cd0..a9f8061e0 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift @@ -128,8 +128,6 @@ public class PrebidAdUnit: NSObject { } adUnit.adUnitConfig.gpid = request.gpid - adUnit.adUnitConfig.impORTBObject = request.impORTBObject - adUnit.adUnitConfig.impExtORTBObject = request.impExtORTBObject adUnit.adUnitConfig.setExtData(request.getExtData()) adUnit.adUnitConfig.setExtKeywords(request.getExtKeywords()) adUnit.adUnitConfig.setAppContent(request.getAppContent()) diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift index c83b09a71..a4227a5f1 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift @@ -28,9 +28,7 @@ public class PrebidRequest: NSObject { private(set) var isRewarded = false private(set) var gpid: String? - private(set) var impORTBObject: [String: Any]? - private(set) var impExtORTBObject: [String: Any]? - + // MARK: - Private properties private var extData = [String: Set]() @@ -55,24 +53,6 @@ public class PrebidRequest: NSObject { self.gpid = gpid } - // MARK: IMP ORTBObject - - /** - For Arbitrary parameters in the imp level - */ - public func setRequestImpOrtbObject(_ ortbObject: [String: Any]?) { - self.impORTBObject = ortbObject - } - - // MARK: IMP EXT ORTBObject - - /** - For Arbitrary parameters in the ext level under imp - */ - public func setRequestImpExtOrtbObject(_ ortbObject: [String: Any]?) { - self.impExtORTBObject = ortbObject - } - // MARK: - adunit ext data aka inventory data (imp[].ext.data) /** diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h index 7657bfd28..477a12602 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h @@ -135,6 +135,9 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong) PBMORTBBidRequestExtPrebid *extPrebid; +@property (nonatomic, strong, nullable) NSDictionary *ortbObject; + + - (instancetype)init; @end diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.m index d8299b584..a81559b49 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.m @@ -68,6 +68,9 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary { ext[@"prebid"] = [[self.extPrebid toJsonDictionary] nullIfEmpty]; ret[@"ext"] = [[ext pbmCopyWithoutEmptyVals] nullIfEmpty]; + for (id key in self.ortbObject) + [ret setObject:[self.ortbObject objectForKey:key] forKey: key]; + ret = [ret pbmCopyWithoutEmptyVals]; return ret; @@ -98,6 +101,8 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona _extPrebid = [[PBMORTBBidRequestExtPrebid alloc] initWithJsonDictionary:jsonDictionary[@"ext"][@"prebid"] ?: @{}]; + _ortbObject = jsonDictionary; + return self; } diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h index 93c05c35c..92cccb132 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h @@ -112,8 +112,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) NSMutableDictionary *extData; @property (nonatomic, strong, nullable) NSString *extKeywords; @property (nonatomic, strong, nullable) NSString *extGPID; -@property (nonatomic, strong, nullable) NSDictionary *impExtORTBObject; -@property (nonatomic, strong, nullable) NSDictionary *impORTBObject; - (instancetype)init; diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m index 62a2475f1..0f642ee28 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m @@ -60,9 +60,6 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary { //loop through extra fields and add arbitrary ones but don't override the previously provided ones //leave this loop at the end of this method so we don't duplicate fields and override provided ones - for (id key in self.impORTBObject) - if ([ret objectForKey:key] == nil) - [ret setObject:[self.impORTBObject objectForKey:key] forKey: key]; ret = [ret pbmCopyWithoutEmptyVals]; @@ -104,11 +101,7 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona _extData = jsonDictionary[@"ext"][@"data"]; _extKeywords = jsonDictionary[@"ext"][@"keywords"]; _extGPID = jsonDictionary[@"ext"][@"gpid"]; - //take all key values stored in ext because they will be filtered before sending - _impExtORTBObject = jsonDictionary[@"ext"]; - - _impORTBObject = jsonDictionary; - + return self; } @@ -139,12 +132,6 @@ - (nonnull PBMJsonDictionary *)extDictionary { if (self.extGPID) { ret[@"gpid"] = self.extGPID; } - - //loop through extra fields and add arbitrary ones but don't override the previously provided ones - //leave this loop at the end of this method so we don't duplicate fields and override provided ones - for (id key in self.impExtORTBObject) - if ([ret objectForKey:key] == nil) - [ret setObject:[self.impExtORTBObject objectForKey:key] forKey: key]; return [ret pbmCopyWithoutEmptyVals]; } diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift index 54456a1d2..4b67f92c0 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift @@ -80,9 +80,7 @@ public class AdUnitConfig: NSObject, NSCopying { public var gpid: String? - public var impExtORTBObject: [String: Any]? - - public var impORTBObject: [String: Any]? + public var ortbObject: [String: Any]? // MARK: - Public Methods diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h index 58267a7d3..15d5ef756 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.h @@ -31,9 +31,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) PBMORTBBidExtSkadn *skadn; -@property (nonatomic, copy, nullable) NSDictionary *ortbObject; - - // This part is dedicating to test server-side ad configurations. // Need to be removed when ext.prebid.passthrough will be available. #if DEBUG diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m index b6c3232c1..ca84c7f04 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m @@ -41,9 +41,7 @@ - (instancetype)initWithJsonDictionary:(PBMJsonDictionary *)jsonDictionary { if (skadnDict) { _skadn = [[PBMORTBBidExtSkadn alloc] initWithJsonDictionary:skadnDict]; } - - _ortbObject = jsonDictionary; - + #if DEBUG NSArray * const passthroughDics = jsonDictionary[@"passthrough"]; _passthrough = nil; @@ -71,12 +69,6 @@ - (PBMJsonDictionary *)toJsonDictionary { ret[@"prebid"] = [self.prebid toJsonDictionary]; ret[@"skadn"] = [self.skadn toJsonDictionary]; - //loop through extra fields and add arbitrary ones but don't override the previously provided ones - //leave this loop at the end of this method so we don't duplicate fields and override provided ones - for (id key in self.ortbObject) - if ([ret objectForKey:key] == nil) - [ret setObject:[self.ortbObject objectForKey:key] forKey: key]; - #if DEBUG NSMutableArray * const passthroughDicArr = [[NSMutableArray alloc] initWithCapacity:self.passthrough.count]; for(PBMORTBExtPrebidPassthrough *nextPassthrough in self.passthrough) { diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m index 33d862ca4..aa1edd051 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m @@ -73,6 +73,7 @@ - (void)buildBidRequest:(nonnull PBMORTBBidRequest *)bidRequest { bidRequest.extPrebid.storedAuctionResponse = Prebid.shared.storedAuctionResponse; bidRequest.extPrebid.dataBidders = self.targeting.accessControlList; bidRequest.extPrebid.storedBidResponses = [Prebid.shared getStoredBidResponses]; + bidRequest.ortbObject = self.adConfiguration.ortbObject; if (Prebid.shared.useCacheForReportingWithRenderingAPI) { PBMMutableJsonDictionary * const cache = [PBMMutableJsonDictionary new]; @@ -178,8 +179,6 @@ - (void)buildBidRequest:(nonnull PBMORTBBidRequest *)bidRequest { nextImp.extPrebid.storedAuctionResponse = Prebid.shared.storedAuctionResponse; nextImp.extPrebid.isRewardedInventory = self.adConfiguration.adConfiguration.isOptIn; nextImp.extGPID = self.adConfiguration.gpid; - nextImp.impExtORTBObject = self.adConfiguration.impExtORTBObject; - nextImp.impORTBObject = self.adConfiguration.impORTBObject; if ([self.adConfiguration getExtData].count > 0) { nextImp.extData = [self.adConfiguration getExtData].mutableCopy; diff --git a/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift b/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift index b9a195f89..168240bec 100644 --- a/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift +++ b/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift @@ -402,45 +402,4 @@ class PrebidAdUnitTests: XCTestCase { waitForExpectations(timeout: 5, handler: nil) } - - func testAdUnitConfiguration_arbitraryParams() { - let expectation = expectation(description: "\(#function)") - expectation.expectedFulfillmentCount = 2 - - let gpid = "/12345/home_screen#identifier" - let impArbitraryParams = ["impparam1": "impparam1", "impparam2": 2, "impparam3": false] as [String : Any] - let extArbitraryParams = ["param1": "param1", "param2": 1, "param3": true] as [String : Any] - var adUnit = PrebidAdUnit(configId: "test-config-id") - - let request = PrebidRequest(bannerParameters: BannerParameters()) - request.setGPID(gpid) - request.setRequestImpOrtbObject(impArbitraryParams) - request.setRequestImpExtOrtbObject(extArbitraryParams) - - // fetchDemand(request:completion) - adUnit.fetchDemand(request: request) { _ in - expectation.fulfill() - XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) - XCTAssertEqual((adUnit.getConfiguration().impORTBObject)?["impparam1"] as? String, "impparam1") - XCTAssertEqual((adUnit.getConfiguration().impORTBObject)?["impparam2"] as? Int, 2) - XCTAssertEqual((adUnit.getConfiguration().impORTBObject)?["impparam3"] as? Bool, false) - XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param1"] as? String, "param1") - XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param2"] as? Int, 1) - XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param3"] as? Bool, true) - } - - let testObject: AnyObject = () as AnyObject - adUnit = PrebidAdUnit(configId: "test-config-id") - - // fetchDemand(adObject:request:completion) - adUnit.fetchDemand(adObject: testObject, request: request) { _ in - expectation.fulfill() - XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) - XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param1"] as? String, "param1") - XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param2"] as? Int, 1) - XCTAssertEqual((adUnit.getConfiguration().impExtORTBObject)?["param3"] as? Bool, true) - } - - waitForExpectations(timeout: 5, handler: nil) - } } diff --git a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift index 6b062793b..2ef82ffab 100644 --- a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift @@ -174,6 +174,11 @@ class PBMORTBAbstractTest : XCTestCase { pbmORTBBidRequest.test = 2 codeAndDecode(abstract: pbmORTBBidRequest, expectedString: "{\"id\":\"\(uuid)\",\"imp\":[{\"clickbrowser\":0,\"ext\":{\"dlp\":1},\"instl\":0,\"secure\":0}],\"test\":2,\"tmax\":2000}") + + pbmORTBBidRequest.ortbObject = ["arbitraryparamkey1": "arbitraryparamvalue1", "imp": [["clickbrowser": 1, "ext": ["dlp":2]]] as [[String : Any]], "tmax": 3000] + + codeAndDecode(abstract: pbmORTBBidRequest, expectedString: "{\"arbitraryparamkey1\":\"arbitraryparamvalue1\",\"id\":\"\(uuid)\",\"imp\":[{\"clickbrowser\":1,\"ext\":{\"dlp\":2}}],\"test\":2,\"tmax\":3000}") + } func testBidRequestExtPrebidToJsonString() { @@ -306,17 +311,6 @@ class PBMORTBAbstractTest : XCTestCase { codeAndDecode(abstract: imp, expectedString: "{\"clickbrowser\":0,\"ext\":{\"dlp\":1,\"gpid\":\"\\/12345\\/home_screen#identifier\"},\"instl\":0,\"secure\":0}") } - func testImpExtArbitraryORTBParams() { - let gpid = "/12345/home_screen#identifier" - - let imp = PBMORTBImp() - imp.extGPID = gpid - imp.impORTBObject = ["impparam1": "impparam1", "impparam2": 2, "impparam3": false, "secure": 1] as [String : Any] - imp.impExtORTBObject = ["param1": "param1", "param2": 1, "param3": true] as [String : Any] - - codeAndDecode(abstract: imp, expectedString: "{\"clickbrowser\":0,\"ext\":{\"dlp\":1,\"gpid\":\"\\/12345\\/home_screen#identifier\",\"param1\":\"param1\",\"param2\":1,\"param3\":true},\"impparam1\":\"impparam1\",\"impparam2\":2,\"impparam3\":false,\"instl\":0,\"secure\":0}") - } - func testBannerToJsonString() { let pbmORTBBanner = PBMORTBBanner() pbmORTBBanner.pos = 1 //Above the fold diff --git a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift index f08141d5b..dd5346507 100644 --- a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift @@ -796,25 +796,6 @@ class PrebidParameterBuilderTest: XCTestCase { XCTAssertEqual(imp.extGPID, gpid) } } - - func testArbitraryORTBParams() { - let gpid = "/12345/home_screen#identifier" - let adUnit = AdUnit(configId: "test", size: CGSize.zero, adFormats: [.banner]) - adUnit.setGPID(gpid) - adUnit.setImpORTBObject(["impLevel1": "param1", "impLevel2": 1, "impLevel3": true] as [String : Any]) - adUnit.setImpExtORTBObject(["param1": "param1", "param2": 1, "param3": true] as [String : Any]) - - let bidRequest = buildBidRequest(with: adUnit.adUnitConfig) - for imp in bidRequest.imp { - XCTAssertEqual(imp.extGPID, gpid) - XCTAssertEqual((imp.impORTBObject)?["impLevel1"] as? String, "param1") - XCTAssertEqual((imp.impORTBObject)?["impLevel2"] as? Int, 1) - XCTAssertEqual((imp.impORTBObject)?["impLevel3"] as? Bool, true) - XCTAssertEqual((imp.impExtORTBObject)?["param1"] as? String, "param1") - XCTAssertEqual((imp.impExtORTBObject)?["param2"] as? Int, 1) - XCTAssertEqual((imp.impExtORTBObject)?["param3"] as? Bool, true) - } - } // MARK: - Helpers diff --git a/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift b/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift index e4b93cce6..28a55da38 100644 --- a/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift @@ -166,7 +166,6 @@ class PBMORTBTest: XCTestCase { "hb_cache_id": "32541b8f-5d49-446d-ae26-18629273a6fe", ] prebid.type = "banner" - ext.ortbObject = ["arbitraryParam1": "param1", "arbitraryParam2": 1, "arbitraryParam3": true] as [String : Any] ext.prebid = prebid ext.bidder = [ "ad_ox_cats": [ @@ -183,7 +182,7 @@ class PBMORTBTest: XCTestCase { "next_highest_bid_price": 0.099, ] - codeAndDecode(abstract: ext, expectedString: "{\"arbitraryParam1\":\"param1\",\"arbitraryParam2\":1,\"arbitraryParam3\":true,\"bidder\":{\"ad_ox_cats\":[2],\"agency_id\":\"agency_10\",\"brand_id\":\"brand_10\",\"buyer_id\":\"buyer_10\",\"matching_ad_id\":{\"campaign_id\":1,\"creative_id\":3,\"placement_id\":2},\"next_highest_bid_price\":0.099000000000000005},\"prebid\":{\"cache\":{\"bids\":{\"cacheId\":\"32541b8f-5d49-446d-ae26-18629273a6fe\",\"url\":\"prebid.devint.openx.net\\/cache?uuid=32541b8f-5d49-446d-ae26-18629273a6fe\"},\"key\":\"kkk\",\"url\":\"some\\/url\"},\"targeting\":{\"hb_bidder\":\"openx\",\"hb_cache_host\":\"prebid.devint.openx.net\",\"hb_cache_id\":\"32541b8f-5d49-446d-ae26-18629273a6fe\",\"hb_cache_path\":\"\\/cache\"},\"type\":\"banner\"}}") + codeAndDecode(abstract: ext, expectedString: "{\"bidder\":{\"ad_ox_cats\":[2],\"agency_id\":\"agency_10\",\"brand_id\":\"brand_10\",\"buyer_id\":\"buyer_10\",\"matching_ad_id\":{\"campaign_id\":1,\"creative_id\":3,\"placement_id\":2},\"next_highest_bid_price\":0.099000000000000005},\"prebid\":{\"cache\":{\"bids\":{\"cacheId\":\"32541b8f-5d49-446d-ae26-18629273a6fe\",\"url\":\"prebid.devint.openx.net\\/cache?uuid=32541b8f-5d49-446d-ae26-18629273a6fe\"},\"key\":\"kkk\",\"url\":\"some\\/url\"},\"targeting\":{\"hb_bidder\":\"openx\",\"hb_cache_host\":\"prebid.devint.openx.net\",\"hb_cache_id\":\"32541b8f-5d49-446d-ae26-18629273a6fe\",\"hb_cache_path\":\"\\/cache\"},\"type\":\"banner\"}}") } func testBidResponseExt() { From 79fde02f81f7ae4b2bc49988a71a34e8894a8aea Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Thu, 4 Jan 2024 12:16:53 -0600 Subject: [PATCH 12/27] fixes --- PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift | 1 + PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift | 2 +- .../PrebidMobileRendering/ORTB/PBMORTBBidRequest.h | 1 - PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m | 7 ++----- .../Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m | 4 +--- .../RenderingTests/Tests/PBMORTBParameterBuilderTest.swift | 2 +- .../RenderingTests/Tests/Prebid/PBMORTBTest.swift | 1 + 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift index a9f8061e0..3098506f2 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift @@ -128,6 +128,7 @@ public class PrebidAdUnit: NSObject { } adUnit.adUnitConfig.gpid = request.gpid + adUnit.adUnitConfig.setExtData(request.getExtData()) adUnit.adUnitConfig.setExtKeywords(request.getExtKeywords()) adUnit.adUnitConfig.setAppContent(request.getAppContent()) diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift index a4227a5f1..ce43ed397 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift @@ -28,7 +28,7 @@ public class PrebidRequest: NSObject { private(set) var isRewarded = false private(set) var gpid: String? - + // MARK: - Private properties private var extData = [String: Set]() diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h index 477a12602..5cf194c14 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h @@ -137,7 +137,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) NSDictionary *ortbObject; - - (instancetype)init; @end diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m index 0f642ee28..6c6b06010 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m @@ -58,9 +58,6 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary { ret[@"ext"] = [[self extDictionary] nullIfEmpty]; - //loop through extra fields and add arbitrary ones but don't override the previously provided ones - //leave this loop at the end of this method so we don't duplicate fields and override provided ones - ret = [ret pbmCopyWithoutEmptyVals]; return ret; @@ -101,7 +98,7 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona _extData = jsonDictionary[@"ext"][@"data"]; _extKeywords = jsonDictionary[@"ext"][@"keywords"]; _extGPID = jsonDictionary[@"ext"][@"gpid"]; - + return self; } @@ -132,7 +129,7 @@ - (nonnull PBMJsonDictionary *)extDictionary { if (self.extGPID) { ret[@"gpid"] = self.extGPID; } - + return [ret pbmCopyWithoutEmptyVals]; } diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m index ca84c7f04..ccc2bedb5 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/ORTB/Prebid/PBMORTBBidExt.m @@ -41,7 +41,7 @@ - (instancetype)initWithJsonDictionary:(PBMJsonDictionary *)jsonDictionary { if (skadnDict) { _skadn = [[PBMORTBBidExtSkadn alloc] initWithJsonDictionary:skadnDict]; } - + #if DEBUG NSArray * const passthroughDics = jsonDictionary[@"passthrough"]; _passthrough = nil; @@ -80,8 +80,6 @@ - (PBMJsonDictionary *)toJsonDictionary { } #endif - - [ret pbmRemoveEmptyVals]; return ret; diff --git a/PrebidMobileTests/RenderingTests/Tests/PBMORTBParameterBuilderTest.swift b/PrebidMobileTests/RenderingTests/Tests/PBMORTBParameterBuilderTest.swift index 8f6c0d466..ac3fc302a 100644 --- a/PrebidMobileTests/RenderingTests/Tests/PBMORTBParameterBuilderTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/PBMORTBParameterBuilderTest.swift @@ -21,7 +21,7 @@ fileprivate let errorMessage = "MockedRequest.toJsonString error" // MARK: - Mock -class MockedRequest : PBMORTBBidRequest { +class MockedRequest : { override func toJsonString() throws -> String { throw PBMError.error(message: errorMessage, type: .internalError) diff --git a/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift b/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift index 28a55da38..a78164316 100644 --- a/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift @@ -166,6 +166,7 @@ class PBMORTBTest: XCTestCase { "hb_cache_id": "32541b8f-5d49-446d-ae26-18629273a6fe", ] prebid.type = "banner" + ext.prebid = prebid ext.bidder = [ "ad_ox_cats": [ From b0294323fb0642b6133c38fbca30ce14d41be2e7 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Thu, 4 Jan 2024 12:17:49 -0600 Subject: [PATCH 13/27] more syntax --- .../RenderingTests/Tests/PBMORTBParameterBuilderTest.swift | 2 +- PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PrebidMobileTests/RenderingTests/Tests/PBMORTBParameterBuilderTest.swift b/PrebidMobileTests/RenderingTests/Tests/PBMORTBParameterBuilderTest.swift index ac3fc302a..8f6c0d466 100644 --- a/PrebidMobileTests/RenderingTests/Tests/PBMORTBParameterBuilderTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/PBMORTBParameterBuilderTest.swift @@ -21,7 +21,7 @@ fileprivate let errorMessage = "MockedRequest.toJsonString error" // MARK: - Mock -class MockedRequest : { +class MockedRequest : PBMORTBBidRequest { override func toJsonString() throws -> String { throw PBMError.error(message: errorMessage, type: .internalError) diff --git a/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift b/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift index a78164316..432753fdf 100644 --- a/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/Prebid/PBMORTBTest.swift @@ -166,7 +166,7 @@ class PBMORTBTest: XCTestCase { "hb_cache_id": "32541b8f-5d49-446d-ae26-18629273a6fe", ] prebid.type = "banner" - + ext.prebid = prebid ext.bidder = [ "ad_ox_cats": [ From d7ab955c4386ae77fe41eb6b06cc137d03b4695d Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Thu, 4 Jan 2024 12:59:22 -0600 Subject: [PATCH 14/27] Added back imp-level and tests. --- PrebidMobile/AdUnits/AdUnit.swift | 20 +++++-- .../MultiformatAdUnit/PrebidRequest.swift | 2 +- .../PrebidMobileRendering/ORTB/PBMORTBImp.h | 3 + .../PrebidMobileRendering/ORTB/PBMORTBImp.m | 7 +++ .../Prebid/PBMCore/AdUnitConfig.swift | 5 +- .../PBMCore/PBMPrebidParameterBuilder.m | 3 +- .../AdUnitTests/PrebidAdUnitTests.swift | 56 +++++++++++++++++++ .../PrebidParameterBuilderTest.swift | 10 +++- 8 files changed, 96 insertions(+), 10 deletions(-) diff --git a/PrebidMobile/AdUnits/AdUnit.swift b/PrebidMobile/AdUnits/AdUnit.swift index 52f33a830..8d488acb9 100644 --- a/PrebidMobile/AdUnits/AdUnit.swift +++ b/PrebidMobile/AdUnits/AdUnit.swift @@ -387,14 +387,24 @@ public class AdUnit: NSObject, DispatcherDelegate { return adUnitConfig.gpid } - // MARK: ORTBObject + // MARK: Global ORTBObject - public func setOrtbObject(_ ortbObject: [String: Any]?) { - adUnitConfig.ortbObject = ortbObject + public func setGlobalOrtbObject(_ ortbObject: [String: Any]?) { + adUnitConfig.globalOrtbObject = ortbObject } - public func getOrtbObject() -> [String: Any]? { - return adUnitConfig.ortbObject + public func getGlobalOrtbObject() -> [String: Any]? { + return adUnitConfig.globalOrtbObject + } + + // MARK: imp-level ORTBObject + + public func setImpOrtbObject(_ ortbObject: [String: Any]?) { + adUnitConfig.impOrtbObject = ortbObject + } + + public func getImpOrtbObject() -> [String: Any]? { + return adUnitConfig.impOrtbObject } // MARK: - others diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift index ce43ed397..4939cc84c 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift @@ -28,7 +28,7 @@ public class PrebidRequest: NSObject { private(set) var isRewarded = false private(set) var gpid: String? - + // MARK: - Private properties private var extData = [String: Set]() diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h index 92cccb132..50d319f8b 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h @@ -113,6 +113,9 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) NSString *extKeywords; @property (nonatomic, strong, nullable) NSString *extGPID; +@property (nonatomic, strong, nullable) NSDictionary *ortbObject; + + - (instancetype)init; @end diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m index 6c6b06010..bd54eb011 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m @@ -58,6 +58,11 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary { ret[@"ext"] = [[self extDictionary] nullIfEmpty]; + //loop through extra fields and add arbitrary ones but don't override the previously provided ones + //leave this loop at the end of this method so we don't duplicate fields and override provided ones + for (id key in self.ortbObject) + [ret setObject:[self.ortbObject objectForKey:key] forKey: key]; + ret = [ret pbmCopyWithoutEmptyVals]; return ret; @@ -99,6 +104,8 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona _extKeywords = jsonDictionary[@"ext"][@"keywords"]; _extGPID = jsonDictionary[@"ext"][@"gpid"]; + _ortbObject = jsonDictionary; + return self; } diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift index 4b67f92c0..33f208b03 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift @@ -80,7 +80,10 @@ public class AdUnitConfig: NSObject, NSCopying { public var gpid: String? - public var ortbObject: [String: Any]? + public var globalOrtbObject: [String: Any]? + + public var impOrtbObject: [String: Any]? + // MARK: - Public Methods diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m index aa1edd051..aef2450d6 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m @@ -73,7 +73,7 @@ - (void)buildBidRequest:(nonnull PBMORTBBidRequest *)bidRequest { bidRequest.extPrebid.storedAuctionResponse = Prebid.shared.storedAuctionResponse; bidRequest.extPrebid.dataBidders = self.targeting.accessControlList; bidRequest.extPrebid.storedBidResponses = [Prebid.shared getStoredBidResponses]; - bidRequest.ortbObject = self.adConfiguration.ortbObject; + bidRequest.ortbObject = self.adConfiguration.globalOrtbObject; if (Prebid.shared.useCacheForReportingWithRenderingAPI) { PBMMutableJsonDictionary * const cache = [PBMMutableJsonDictionary new]; @@ -179,6 +179,7 @@ - (void)buildBidRequest:(nonnull PBMORTBBidRequest *)bidRequest { nextImp.extPrebid.storedAuctionResponse = Prebid.shared.storedAuctionResponse; nextImp.extPrebid.isRewardedInventory = self.adConfiguration.adConfiguration.isOptIn; nextImp.extGPID = self.adConfiguration.gpid; + nextImp.ortbObject = self.adConfiguration.impOrtbObject; if ([self.adConfiguration getExtData].count > 0) { nextImp.extData = [self.adConfiguration getExtData].mutableCopy; diff --git a/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift b/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift index 168240bec..1a55c05bb 100644 --- a/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift +++ b/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift @@ -402,4 +402,60 @@ class PrebidAdUnitTests: XCTestCase { waitForExpectations(timeout: 5, handler: nil) } + + func testAdUnitConfiguration_globalOrtb() { + let expectation = expectation(description: "\(#function)") + expectation.expectedFulfillmentCount = 2 + + let gpid = "/12345/home_screen#identifier" + var adUnit = PrebidAdUnit(configId: "test-config-id") + + let request = PrebidRequest(bannerParameters: BannerParameters()) + request.setGPID(gpid) + + // fetchDemand(request:completion) + adUnit.fetchDemand(request: request) { _ in + expectation.fulfill() + XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) + } + + let testObject: AnyObject = () as AnyObject + adUnit = PrebidAdUnit(configId: "test-config-id") + + // fetchDemand(adObject:request:completion) + adUnit.fetchDemand(adObject: testObject, request: request) { _ in + expectation.fulfill() + XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) + } + + waitForExpectations(timeout: 5, handler: nil) + } + + func testAdUnitConfiguration_impOrtb() { + let expectation = expectation(description: "\(#function)") + expectation.expectedFulfillmentCount = 2 + + let gpid = "/12345/home_screen#identifier" + var adUnit = PrebidAdUnit(configId: "test-config-id") + + let request = PrebidRequest(bannerParameters: BannerParameters()) + request.setGPID(gpid) + + // fetchDemand(request:completion) + adUnit.fetchDemand(request: request) { _ in + expectation.fulfill() + XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) + } + + let testObject: AnyObject = () as AnyObject + adUnit = PrebidAdUnit(configId: "test-config-id") + + // fetchDemand(adObject:request:completion) + adUnit.fetchDemand(adObject: testObject, request: request) { _ in + expectation.fulfill() + XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) + } + + waitForExpectations(timeout: 5, handler: nil) + } } diff --git a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift index dd5346507..b7222876b 100644 --- a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift @@ -785,15 +785,21 @@ class PrebidParameterBuilderTest: XCTestCase { } } - func testGlobalArbitraryORTBParams() { + func testArbitraryORTBParams() { let gpid = "/12345/home_screen#identifier" + let globalOrtb = ["arbitraryparam1": "param1", "arbitraryparam2": 2, "arbitraryparam3": false] as [String : Any] + let impOrtb = ["arbimpparam1": "impparam1", "arbitraryparam2": 2, "arbitraryparam3": false] as [String : Any] let adUnit = AdUnit(configId: "test", size: CGSize.zero, adFormats: [.banner]) adUnit.setGPID(gpid) + adUnit.setGlobalOrtbObject(globalOrtb) + adUnit.setImpOrtbObject(impOrtb) let bidRequest = buildBidRequest(with: adUnit.adUnitConfig) + XCTAssertEqual(bidRequest.ortbObject?["arbitraryparam1"] as! String, "param1") + for imp in bidRequest.imp { - XCTAssertEqual(imp.extGPID, gpid) + XCTAssertEqual(imp.ortbObject?["arbimpparam1"] as! String, "impparam1") } } From 473684e21de2e1e72cfd81388e19a8203511251e Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Thu, 4 Jan 2024 13:03:10 -0600 Subject: [PATCH 15/27] Remove from test. --- .../AdUnitTests/PrebidAdUnitTests.swift | 56 ------------------- .../Tests/PBMORTBAbstractTest.swift | 2 +- 2 files changed, 1 insertion(+), 57 deletions(-) diff --git a/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift b/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift index 1a55c05bb..168240bec 100644 --- a/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift +++ b/PrebidMobileTests/AdUnitTests/PrebidAdUnitTests.swift @@ -402,60 +402,4 @@ class PrebidAdUnitTests: XCTestCase { waitForExpectations(timeout: 5, handler: nil) } - - func testAdUnitConfiguration_globalOrtb() { - let expectation = expectation(description: "\(#function)") - expectation.expectedFulfillmentCount = 2 - - let gpid = "/12345/home_screen#identifier" - var adUnit = PrebidAdUnit(configId: "test-config-id") - - let request = PrebidRequest(bannerParameters: BannerParameters()) - request.setGPID(gpid) - - // fetchDemand(request:completion) - adUnit.fetchDemand(request: request) { _ in - expectation.fulfill() - XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) - } - - let testObject: AnyObject = () as AnyObject - adUnit = PrebidAdUnit(configId: "test-config-id") - - // fetchDemand(adObject:request:completion) - adUnit.fetchDemand(adObject: testObject, request: request) { _ in - expectation.fulfill() - XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) - } - - waitForExpectations(timeout: 5, handler: nil) - } - - func testAdUnitConfiguration_impOrtb() { - let expectation = expectation(description: "\(#function)") - expectation.expectedFulfillmentCount = 2 - - let gpid = "/12345/home_screen#identifier" - var adUnit = PrebidAdUnit(configId: "test-config-id") - - let request = PrebidRequest(bannerParameters: BannerParameters()) - request.setGPID(gpid) - - // fetchDemand(request:completion) - adUnit.fetchDemand(request: request) { _ in - expectation.fulfill() - XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) - } - - let testObject: AnyObject = () as AnyObject - adUnit = PrebidAdUnit(configId: "test-config-id") - - // fetchDemand(adObject:request:completion) - adUnit.fetchDemand(adObject: testObject, request: request) { _ in - expectation.fulfill() - XCTAssertEqual(adUnit.getConfiguration().gpid, gpid) - } - - waitForExpectations(timeout: 5, handler: nil) - } } diff --git a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift index 2ef82ffab..c329cf5a1 100644 --- a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift @@ -175,7 +175,7 @@ class PBMORTBAbstractTest : XCTestCase { codeAndDecode(abstract: pbmORTBBidRequest, expectedString: "{\"id\":\"\(uuid)\",\"imp\":[{\"clickbrowser\":0,\"ext\":{\"dlp\":1},\"instl\":0,\"secure\":0}],\"test\":2,\"tmax\":2000}") - pbmORTBBidRequest.ortbObject = ["arbitraryparamkey1": "arbitraryparamvalue1", "imp": [["clickbrowser": 1, "ext": ["dlp":2]]] as [[String : Any]], "tmax": 3000] + pbmORTBBidRequest.ortbObject = ["arbitraryparamkey1": "arbitraryparamvalue1", "tmax": 3000] codeAndDecode(abstract: pbmORTBBidRequest, expectedString: "{\"arbitraryparamkey1\":\"arbitraryparamvalue1\",\"id\":\"\(uuid)\",\"imp\":[{\"clickbrowser\":1,\"ext\":{\"dlp\":2}}],\"test\":2,\"tmax\":3000}") From 5579256364dd8b708eccad9dd0fc310535713090 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Thu, 4 Jan 2024 17:22:42 -0600 Subject: [PATCH 16/27] Fixed test --- PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift | 2 +- .../RenderingTests/Tests/PBMORTBAbstractTest.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift index 4939cc84c..ce43ed397 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift @@ -28,7 +28,7 @@ public class PrebidRequest: NSObject { private(set) var isRewarded = false private(set) var gpid: String? - + // MARK: - Private properties private var extData = [String: Set]() diff --git a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift index c329cf5a1..838e70a9b 100644 --- a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift @@ -177,7 +177,7 @@ class PBMORTBAbstractTest : XCTestCase { pbmORTBBidRequest.ortbObject = ["arbitraryparamkey1": "arbitraryparamvalue1", "tmax": 3000] - codeAndDecode(abstract: pbmORTBBidRequest, expectedString: "{\"arbitraryparamkey1\":\"arbitraryparamvalue1\",\"id\":\"\(uuid)\",\"imp\":[{\"clickbrowser\":1,\"ext\":{\"dlp\":2}}],\"test\":2,\"tmax\":3000}") + codeAndDecode(abstract: pbmORTBBidRequest, expectedString: "{\"arbitraryparamkey1\":\"arbitraryparamvalue1\",\"id\":\"\(uuid)\",\"imp\":[{\"clickbrowser\":0,\"ext\":{\"dlp\":1},\"instl\":0,\"secure\":0}],\"test\":2,\"tmax\":3000}") } From 452b4e6ad75586d3fee7db52fee8e30a67e7696a Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 1 Nov 2023 12:10:44 -0500 Subject: [PATCH 17/27] Makes unregister function public. --- PrebidMobile/AdUnits/Native/NativeAd.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index 242098d98..31c37a748 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -182,7 +182,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { return true } - private func unregisterViewFromTracking() { + func unregisterViewFromTracking() { detachAllGestureRecognizers() viewForTracking = nil invalidateTimer(viewabilityTimer) From 8a87df7f81ed49e84a644f6e1a1b8af56a7f2386 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 1 Nov 2023 13:28:16 -0500 Subject: [PATCH 18/27] checking for nil and invalidating timer but may have to dive deeper for deinit. --- PrebidMobile/AdUnits/Native/NativeAd.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index 31c37a748..19b7c2d54 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -36,7 +36,13 @@ public class NativeAd: NSObject, CacheExpiryDelegate { private var viewabilityTimer: Timer? private var viewabilityValue = 0 private var impressionHasBeenTracked = false - private weak var viewForTracking: UIView? + private weak var viewForTracking: UIView? { + didSet { + if (viewForTracking == nil) { + invalidateTimer(viewabilityTimer) + } + } + } //Click Handling private var gestureRecognizerRecords = [NativeAdGestureRecognizerRecord]() @@ -182,7 +188,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { return true } - func unregisterViewFromTracking() { + private func unregisterViewFromTracking() { detachAllGestureRecognizers() viewForTracking = nil invalidateTimer(viewabilityTimer) From 036bdbb2fdf032c37733fbc02338649fe42b250a Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 1 Nov 2023 12:10:44 -0500 Subject: [PATCH 19/27] Makes unregister function public. --- PrebidMobile/AdUnits/Native/NativeAd.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index 19b7c2d54..d3e4a05fd 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -188,7 +188,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { return true } - private func unregisterViewFromTracking() { + func unregisterViewFromTracking() { detachAllGestureRecognizers() viewForTracking = nil invalidateTimer(viewabilityTimer) From 27747b58ccc68da9878073ad2a5f62f761d5500b Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 1 Nov 2023 13:28:16 -0500 Subject: [PATCH 20/27] checking for nil and invalidating timer but may have to dive deeper for deinit. --- PrebidMobile/AdUnits/Native/NativeAd.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index d3e4a05fd..19b7c2d54 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -188,7 +188,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { return true } - func unregisterViewFromTracking() { + private func unregisterViewFromTracking() { detachAllGestureRecognizers() viewForTracking = nil invalidateTimer(viewabilityTimer) From 028071192d520af5f05ab27dc5c4218780e2b526 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Tue, 16 Jan 2024 10:59:50 -0600 Subject: [PATCH 21/27] We believe there may be some type casting issues that are causing the timer to fire every 0.1ms instead of 4 times/second. This hopefully will fix them. --- PrebidMobile/AdUnits/Native/NativeAd.swift | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index 19b7c2d54..8ad2c2ff6 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -27,7 +27,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { // MARK: - Internal properties private static let nativeAdIABShouldBeViewableForTrackingDuration = 1.0 - private static let nativeAdCheckViewabilityForTrackingFrequency = 0.25 + private static let nativeAdCheckViewabilityForTrackingFrequency: Double = 0.25 //NativeAd Expire private var expired = false @@ -36,13 +36,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { private var viewabilityTimer: Timer? private var viewabilityValue = 0 private var impressionHasBeenTracked = false - private weak var viewForTracking: UIView? { - didSet { - if (viewForTracking == nil) { - invalidateTimer(viewabilityTimer) - } - } - } + private weak var viewForTracking: UIView? //Click Handling private var gestureRecognizerRecords = [NativeAdGestureRecognizerRecord]() @@ -218,7 +212,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { Log.debug("\n\trequiredAmountOfSimultaneousViewableEvents=\(requiredAmountOfSimultaneousViewableEvents) \n\ttargetViewabilityValue=\(targetViewabilityValue)") - viewabilityTimer = Timer.scheduledTimer(withTimeInterval: NativeAd.nativeAdCheckViewabilityForTrackingFrequency, repeats: true) { [weak self] timer in + viewabilityTimer = Timer.scheduledTimer(withTimeInterval: TimeInterval(NativeAd.nativeAdCheckViewabilityForTrackingFrequency), repeats: true) { [weak self] timer in guard let strongSelf = self else { timer.invalidate() Log.debug("FAILED TO ACQUIRE strongSelf viewabilityTimer") From e8c17c0db037a93abe6b2a83664d869eada522b6 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Tue, 16 Jan 2024 13:04:32 -0600 Subject: [PATCH 22/27] Needed to change the check bounds to make sure isIABViewable is true at the correct time! --- PrebidMobile/UIViewExtension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PrebidMobile/UIViewExtension.swift b/PrebidMobile/UIViewExtension.swift index bb0cb0915..8536498d2 100644 --- a/PrebidMobile/UIViewExtension.swift +++ b/PrebidMobile/UIViewExtension.swift @@ -39,7 +39,7 @@ extension UIView { } let screenRect = UIScreen.main.bounds - let normalizedSelfRect = convert(screenRect, to: nil) + let normalizedSelfRect = convert(self.bounds, to: nil) let intersection = screenRect.intersection(normalizedSelfRect) if intersection.equalTo(.null) { return false From 428e9a52395572fdf639ea8005505bb3630bd798 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Tue, 16 Jan 2024 13:05:36 -0600 Subject: [PATCH 23/27] removed previous changes. --- PrebidMobile/AdUnits/Native/NativeAd.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index 8ad2c2ff6..242098d98 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -27,7 +27,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { // MARK: - Internal properties private static let nativeAdIABShouldBeViewableForTrackingDuration = 1.0 - private static let nativeAdCheckViewabilityForTrackingFrequency: Double = 0.25 + private static let nativeAdCheckViewabilityForTrackingFrequency = 0.25 //NativeAd Expire private var expired = false @@ -212,7 +212,7 @@ public class NativeAd: NSObject, CacheExpiryDelegate { Log.debug("\n\trequiredAmountOfSimultaneousViewableEvents=\(requiredAmountOfSimultaneousViewableEvents) \n\ttargetViewabilityValue=\(targetViewabilityValue)") - viewabilityTimer = Timer.scheduledTimer(withTimeInterval: TimeInterval(NativeAd.nativeAdCheckViewabilityForTrackingFrequency), repeats: true) { [weak self] timer in + viewabilityTimer = Timer.scheduledTimer(withTimeInterval: NativeAd.nativeAdCheckViewabilityForTrackingFrequency, repeats: true) { [weak self] timer in guard let strongSelf = self else { timer.invalidate() Log.debug("FAILED TO ACQUIRE strongSelf viewabilityTimer") From a9d03e4ad3593ac306f68e566756e36ee720c74e Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Wed, 17 Jan 2024 09:44:31 -0600 Subject: [PATCH 24/27] Proposed changes. --- PrebidMobile/AdUnits/Native/NativeAd.swift | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index 242098d98..39e59b27d 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -176,10 +176,14 @@ public class NativeAd: NSObject, CacheExpiryDelegate { Log.error("The native Ad is expired, cannot use it for tracking") return false } - viewForTracking = view - setupViewabilityTracker() - attachGestureRecognizersToNativeView(nativeView: view, withClickableViews: clickableViews) - return true + if (viewForTracking != nil || impressionHasBeenTracked) { + return false + } else { + viewForTracking = view + setupViewabilityTracker() + attachGestureRecognizersToNativeView(nativeView: view, withClickableViews: clickableViews) + return true + } } private func unregisterViewFromTracking() { @@ -219,6 +223,9 @@ public class NativeAd: NSObject, CacheExpiryDelegate { return } strongSelf.checkViewability() + if (strongSelf.viewForTracking == nil) { + timer.invalidate() + } } } From 8b7b66e68d36dc085f8665408547cb90bf27d9f3 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Fri, 19 Jan 2024 12:10:49 -0600 Subject: [PATCH 25/27] changes for 2.2.0 release --- .../EventHandlers.xcodeproj/project.pbxproj | 26 +++++++++---------- PrebidMobile.podspec | 2 +- PrebidMobile.xcodeproj/project.pbxproj | 10 +++---- PrebidMobile/Constants.swift | 2 +- PrebidMobileAdMobAdapters.podspec | 4 +-- PrebidMobileGAMEventHandlers.podspec | 4 +-- PrebidMobileMAXAdapters.podspec | 4 +-- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/EventHandlers/EventHandlers.xcodeproj/project.pbxproj b/EventHandlers/EventHandlers.xcodeproj/project.pbxproj index e1d378ca2..6eb9d7457 100644 --- a/EventHandlers/EventHandlers.xcodeproj/project.pbxproj +++ b/EventHandlers/EventHandlers.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -1200,7 +1200,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 2.1.6; + CURRENT_PROJECT_VERSION = 2.2.0; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1214,7 +1214,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.1.6; + MARKETING_VERSION = 2.2.0; MODULEMAP_FILE = ""; PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileGAMEventHandlers; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -1235,7 +1235,7 @@ CLANG_ENABLE_MODULES = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 2.1.6; + CURRENT_PROJECT_VERSION = 2.2.0; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1249,7 +1249,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.1.6; + MARKETING_VERSION = 2.2.0; MODULEMAP_FILE = ""; PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileGAMEventHandlers; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -1269,7 +1269,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2.1.6; + CURRENT_PROJECT_VERSION = 2.2.0; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1284,7 +1284,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.1.6; + MARKETING_VERSION = 2.2.0; PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileMAXAdapters; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -1304,7 +1304,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2.1.6; + CURRENT_PROJECT_VERSION = 2.2.0; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1319,7 +1319,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.1.6; + MARKETING_VERSION = 2.2.0; PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileMAXAdapters; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -1381,7 +1381,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2.1.6; + CURRENT_PROJECT_VERSION = 2.2.0; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -1395,7 +1395,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.1.6; + MARKETING_VERSION = 2.2.0; PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileAdMobAdapters; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = None; @@ -1416,7 +1416,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2.1.6; + CURRENT_PROJECT_VERSION = 2.2.0; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -1430,7 +1430,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.1.6; + MARKETING_VERSION = 2.2.0; PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileAdMobAdapters; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = None; diff --git a/PrebidMobile.podspec b/PrebidMobile.podspec index 777fc2676..0fcdfc431 100644 --- a/PrebidMobile.podspec +++ b/PrebidMobile.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "PrebidMobile" - s.version = "2.1.6" + s.version = "2.2.0" s.summary = "PrebidMobile is a lightweight framework that integrates directly with Prebid Server." s.description = <<-DESC diff --git a/PrebidMobile.xcodeproj/project.pbxproj b/PrebidMobile.xcodeproj/project.pbxproj index 317e3eeab..f492191e8 100644 --- a/PrebidMobile.xcodeproj/project.pbxproj +++ b/PrebidMobile.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -4455,7 +4455,7 @@ CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; - CURRENT_PROJECT_VERSION = 2.1.6; + CURRENT_PROJECT_VERSION = 2.2.0; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -4474,7 +4474,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.1.6; + MARKETING_VERSION = 2.2.0; MODULEMAP_FILE = PrebidMobile/BuildFiles/PrebidMobile.modulemap; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -4491,7 +4491,7 @@ CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; - CURRENT_PROJECT_VERSION = 2.1.6; + CURRENT_PROJECT_VERSION = 2.2.0; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -4510,7 +4510,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.1.6; + MARKETING_VERSION = 2.2.0; MODULEMAP_FILE = PrebidMobile/BuildFiles/PrebidMobile.modulemap; SKIP_INSTALL = YES; SWIFT_VERSION = 5.0; diff --git a/PrebidMobile/Constants.swift b/PrebidMobile/Constants.swift index dd952d83d..81334a91c 100644 --- a/PrebidMobile/Constants.swift +++ b/PrebidMobile/Constants.swift @@ -18,7 +18,7 @@ import UIKit public let PrebidLocalCacheIdKey = "hb_cache_id_local" @objc public class Constants: NSObject { - @objc public static let PREBID_VERSION = "2.1.6" + @objc public static let PREBID_VERSION = "2.2.0" } extension String { diff --git a/PrebidMobileAdMobAdapters.podspec b/PrebidMobileAdMobAdapters.podspec index 4d6cc86f3..4b6eb9218 100644 --- a/PrebidMobileAdMobAdapters.podspec +++ b/PrebidMobileAdMobAdapters.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "PrebidMobileAdMobAdapters" - s.version = "2.1.6" + s.version = "2.2.0" s.summary = "The bridge between PrebidMobile SDK and GMA SDK." s.description = "AdMob Adatpers manages rendering of Prebid ads in the case of integration with AdMob as a Primary Ad Server." @@ -40,7 +40,7 @@ Pod::Spec.new do |s| s.static_framework = true - s.dependency 'PrebidMobile', '2.1.6' + s.dependency 'PrebidMobile', '2.2.0' s.dependency 'Google-Mobile-Ads-SDK' end diff --git a/PrebidMobileGAMEventHandlers.podspec b/PrebidMobileGAMEventHandlers.podspec index d0a8dcfb3..da9707fa2 100644 --- a/PrebidMobileGAMEventHandlers.podspec +++ b/PrebidMobileGAMEventHandlers.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "PrebidMobileGAMEventHandlers" - s.version = "2.1.6" + s.version = "2.2.0" s.summary = "The bridge between PrebidMobile SDK and GMA SDK." s.description = "GAM Event Handlers manages rendering of Prebid or GAM ads respectively to the winning bid." @@ -39,7 +39,7 @@ Pod::Spec.new do |s| s.source_files = 'EventHandlers/PrebidMobileGAMEventHandlers/**/*.{h,m,swift}' s.static_framework = true - s.dependency 'PrebidMobile', '2.1.6' + s.dependency 'PrebidMobile', '2.2.0' s.dependency 'Google-Mobile-Ads-SDK' end diff --git a/PrebidMobileMAXAdapters.podspec b/PrebidMobileMAXAdapters.podspec index 328615be4..e2e49b117 100644 --- a/PrebidMobileMAXAdapters.podspec +++ b/PrebidMobileMAXAdapters.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "PrebidMobileMAXAdapters" - s.version = "2.1.6" + s.version = "2.2.0" s.summary = "The bridge between PrebidMobile SDK and Applovin MAX SDK." s.description = "MAX Adapters manages rendering of Prebid or MAX ads respectively to the winning bid." @@ -39,7 +39,7 @@ Pod::Spec.new do |s| s.source_files = 'EventHandlers/PrebidMobileMAXAdapters/**/*.{h,m,swift}' s.static_framework = true - s.dependency 'PrebidMobile', '2.1.6' + s.dependency 'PrebidMobile', '2.2.0' s.dependency 'AppLovinSDK' end From be7479588ed17d194ba2b6aa63a9d8e0c9c4b31a Mon Sep 17 00:00:00 2001 From: Jono Sligh <139150153+jsligh@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:18:21 -0600 Subject: [PATCH 26/27] Update README.md Add carthage change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff71afd9b..aff8b4a40 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Run the test script to run unit tests and integration tests. `2.1.6` version is available to build PrebidMobile with Carthage. For that, please, put the following content to your `Cartfile`: ``` -github "prebid/prebid-mobile-ios" == 2.1.6-carthage +github "prebid/prebid-mobile-ios" == 2.2.0-carthage ``` Run this command in order to build PrebidMobile with Carthage: From 843ad3a5147bbf1e56b3923349533ca7039c93a0 Mon Sep 17 00:00:00 2001 From: Jono Sligh Date: Fri, 9 Feb 2024 12:23:10 -0600 Subject: [PATCH 27/27] Pretty Sure my merging logic is correct. --- PrebidMobile/AdUnits/AdUnit.swift | 20 ++----- .../MultiformatAdUnit/PrebidRequest.swift | 2 + .../AdTypes/AdView/AdConfiguration.swift | 3 + .../Parameters/PBMParameterBuilderService.m | 4 +- .../ORTB/PBMORTBBidRequest.h | 2 + .../ORTB/PBMORTBBidRequest.m | 55 ++++++++++++++++++- .../PrebidMobileRendering/ORTB/PBMORTBImp.h | 3 - .../PrebidMobileRendering/ORTB/PBMORTBImp.m | 7 --- .../Prebid/Integrations/GAM/BannerView.swift | 5 ++ .../GAM/BaseInterstitialAdUnit.swift | 5 ++ .../MediationAPI/MediationBannerAdUnit.swift | 5 ++ .../MediationBaseInterstitialAdUnit.swift | 5 ++ .../MediationAPI/MediationNativeAdUnit.swift | 9 +++ .../Prebid/PBMCore/AdUnitConfig.swift | 8 +-- .../PBMCore/PBMPrebidParameterBuilder.m | 2 - .../Tests/PBMORTBAbstractTest.swift | 4 +- .../PrebidParameterBuilderTest.swift | 12 +--- 17 files changed, 105 insertions(+), 46 deletions(-) diff --git a/PrebidMobile/AdUnits/AdUnit.swift b/PrebidMobile/AdUnits/AdUnit.swift index 8d488acb9..9e6cce229 100644 --- a/PrebidMobile/AdUnits/AdUnit.swift +++ b/PrebidMobile/AdUnits/AdUnit.swift @@ -24,7 +24,7 @@ public class AdUnit: NSObject, DispatcherDelegate { var adSizes: [CGSize] { get { [adUnitConfig.adSize] + (adUnitConfig.additionalSizes ?? []) } } - + private static let PB_MIN_RefreshTime = 30000.0 private(set) var dispatcher: Dispatcher? @@ -389,22 +389,12 @@ public class AdUnit: NSObject, DispatcherDelegate { // MARK: Global ORTBObject - public func setGlobalOrtbObject(_ ortbObject: [String: Any]?) { - adUnitConfig.globalOrtbObject = ortbObject - } - - public func getGlobalOrtbObject() -> [String: Any]? { - return adUnitConfig.globalOrtbObject - } - - // MARK: imp-level ORTBObject - - public func setImpOrtbObject(_ ortbObject: [String: Any]?) { - adUnitConfig.impOrtbObject = ortbObject + public func setOrtbConfig(_ ortbObject: [String: Any]?) { + adUnitConfig.ortbConfig = ortbObject } - public func getImpOrtbObject() -> [String: Any]? { - return adUnitConfig.impOrtbObject + public func getOrtbConfig() -> [String: Any]? { + return adUnitConfig.ortbConfig } // MARK: - others diff --git a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift index ce43ed397..c55b661dc 100644 --- a/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift +++ b/PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift @@ -29,6 +29,8 @@ public class PrebidRequest: NSObject { private(set) var gpid: String? + private(set) var ortbConfig: [String: Any]? + // MARK: - Private properties private var extData = [String: Set]() diff --git a/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/AdConfiguration.swift b/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/AdConfiguration.swift index a335cb37d..7ff3c52f9 100644 --- a/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/AdConfiguration.swift +++ b/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/AdConfiguration.swift @@ -122,7 +122,10 @@ public class AdConfiguration: AutoRefreshCountConfig { public var clickHandlerOverride: ((PBMVoidBlock) -> Void)? + public var ortbConfig: [String: Any]? + // MARK: Private properties private var _autoRefreshDelay: TimeInterval? = PBMAutoRefresh.AUTO_REFRESH_DELAY_DEFAULT + } diff --git a/PrebidMobile/PrebidMobileRendering/Networking/Parameters/PBMParameterBuilderService.m b/PrebidMobile/PrebidMobileRendering/Networking/Parameters/PBMParameterBuilderService.m index 2a8ec47b1..d0b5b55d9 100644 --- a/PrebidMobile/PrebidMobileRendering/Networking/Parameters/PBMParameterBuilderService.m +++ b/PrebidMobile/PrebidMobileRendering/Networking/Parameters/PBMParameterBuilderService.m @@ -45,6 +45,7 @@ @implementation PBMParameterBuilderService } + (nonnull NSDictionary *)buildParamsDictWithAdConfiguration:(nonnull PBMAdConfiguration *)adConfiguration extraParameterBuilders:(nullable NSArray > *)extraParameterBuilders { + //build return [self buildParamsDictWithAdConfiguration:adConfiguration bundle:NSBundle.mainBundle pbmLocationManager:PBMLocationManager.shared @@ -71,6 +72,7 @@ @implementation PBMParameterBuilderService extraParameterBuilders:(nullable NSArray > *)extraParameterBuilders{ PBMORTBBidRequest *bidRequest = [PBMParameterBuilderService createORTBBidRequestWithTargeting:targeting]; + bidRequest.ortbObject = adConfiguration.ortbConfig; NSMutableArray > * const parameterBuilders = [[NSMutableArray alloc] init]; [parameterBuilders addObjectsFromArray:@[ [[PBMBasicParameterBuilder alloc] initWithAdConfiguration:adConfiguration @@ -109,7 +111,7 @@ + (nonnull PBMORTBBidRequest *)createORTBBidRequestWithTargeting:(nonnull Target bidRequest.user.buyeruid = targeting.buyerUID; bidRequest.user.customdata = targeting.userCustomData; bidRequest.user.userid = targeting.userID; - + if (targeting.userExt) { bidRequest.user.ext = [targeting.userExt mutableCopy]; } diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h index 5cf194c14..5ffe3c662 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h @@ -135,6 +135,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong) PBMORTBBidRequestExtPrebid *extPrebid; +@property (nonatomic, strong, nullable) NSDictionary *arbitraryJsonConfig; + @property (nonatomic, strong, nullable) NSDictionary *ortbObject; - (instancetype)init; diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.m index a81559b49..ac0220cec 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.m @@ -68,9 +68,58 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary { ext[@"prebid"] = [[self.extPrebid toJsonDictionary] nullIfEmpty]; ret[@"ext"] = [[ext pbmCopyWithoutEmptyVals] nullIfEmpty]; - for (id key in self.ortbObject) - [ret setObject:[self.ortbObject objectForKey:key] forKey: key]; + //remove "protected" fields from ortbObject then do a merge but merge ret into the ortbObject (addEntriesFromDictionary) + NSMutableDictionary *o = [self.arbitraryJsonConfig mutableCopy]; + if (o[@"regs"]) { + o[@"regs"] = nil; + } + if (o[@"device"]) { + o[@"device"] = nil; + } + if (o[@"geo"]) { + o[@"geo"] = nil; + } + //merge with config from API/JSON + ret = [self mergeDictionaries: ret joiningArgument2: o joiningArgument3: false]; + + NSMutableDictionary *o2 = [self.ortbObject mutableCopy]; + + if (o2[@"regs"]) { + o2[@"regs"] = nil; + } + if (o2[@"device"]) { + o2[@"device"] = nil; + } + if (o2[@"geo"]) { + o[@"geo"] = nil; + } + //merge with ortbConfig from SDK + ret = [self mergeDictionaries: ret joiningArgument2: o2 joiningArgument3: true]; + + ret = [ret pbmCopyWithoutEmptyVals]; + return ret; +} + +- (nonnull PBMMutableJsonDictionary *)mergeDictionaries:(NSMutableDictionary*)dictionary1 joiningArgument2:(NSMutableDictionary*)dictionary2 + joiningArgument3:(Boolean)firstHasPriority{ + PBMMutableJsonDictionary *ret = dictionary1; + + for (id key in dictionary2) + if ([ret objectForKey: key]){ + if ([[ret objectForKey: key] isKindOfClass: [NSDictionary class]]) { + //if is dictionary, need to call this method recursively for ret object for key and dictionary2 for key + [ret setObject:[self mergeDictionaries:[ret objectForKey: key] joiningArgument2: [dictionary2 objectForKey: key] joiningArgument3:firstHasPriority] forKey: key]; + } else { + if (!firstHasPriority) { + [ret setObject:[dictionary2 objectForKey: key] forKey:key]; + } + } + //not sure what to do if array of objects + } else { + [ret setObject:[dictionary2 objectForKey:key] forKey: key]; + } + ret = [ret pbmCopyWithoutEmptyVals]; return ret; @@ -101,7 +150,7 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona _extPrebid = [[PBMORTBBidRequestExtPrebid alloc] initWithJsonDictionary:jsonDictionary[@"ext"][@"prebid"] ?: @{}]; - _ortbObject = jsonDictionary; + _arbitraryJsonConfig = jsonDictionary; return self; } diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h index 50d319f8b..92cccb132 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.h @@ -113,9 +113,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) NSString *extKeywords; @property (nonatomic, strong, nullable) NSString *extGPID; -@property (nonatomic, strong, nullable) NSDictionary *ortbObject; - - - (instancetype)init; @end diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m index bd54eb011..6c6b06010 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBImp.m @@ -58,11 +58,6 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary { ret[@"ext"] = [[self extDictionary] nullIfEmpty]; - //loop through extra fields and add arbitrary ones but don't override the previously provided ones - //leave this loop at the end of this method so we don't duplicate fields and override provided ones - for (id key in self.ortbObject) - [ret setObject:[self.ortbObject objectForKey:key] forKey: key]; - ret = [ret pbmCopyWithoutEmptyVals]; return ret; @@ -104,8 +99,6 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona _extKeywords = jsonDictionary[@"ext"][@"keywords"]; _extGPID = jsonDictionary[@"ext"][@"gpid"]; - _ortbObject = jsonDictionary; - return self; } diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/GAM/BannerView.swift b/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/GAM/BannerView.swift index 44d2fe020..9a7f1a728 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/GAM/BannerView.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/GAM/BannerView.swift @@ -64,6 +64,11 @@ public class BannerView: UIView, set { adUnitConfig.adPosition = newValue } } + @objc public var ortbConfig: [String: Any]? { + get { adUnitConfig.ortbConfig } + set { adUnitConfig.ortbConfig = newValue } + } + @objc public weak var delegate: BannerViewDelegate? // MARK: Readonly storage diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/GAM/BaseInterstitialAdUnit.swift b/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/GAM/BaseInterstitialAdUnit.swift index 512ba7815..5cf72df16 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/GAM/BaseInterstitialAdUnit.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/GAM/BaseInterstitialAdUnit.swift @@ -46,6 +46,11 @@ public class BaseInterstitialAdUnit : get { adUnitConfig.adFormats } set { adUnitConfig.adFormats = newValue } } + + @objc public var ortbConfig: [String: Any]? { + get { adUnitConfig.ortbConfig } + set { adUnitConfig.ortbConfig = newValue } + } @objc public var isReady: Bool { objc_sync_enter(blocksLockToken) diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationBannerAdUnit.swift b/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationBannerAdUnit.swift index e3f708acf..87e3b2639 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationBannerAdUnit.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationBannerAdUnit.swift @@ -70,6 +70,11 @@ public class MediationBannerAdUnit : NSObject { set { adUnitConfig.additionalSizes = newValue } } + public var ortbConfig: [String: Any]? { + get { adUnitConfig.ortbConfig } + set { adUnitConfig.ortbConfig = newValue } + } + // MARK: - Ext Data (imp[].ext.data) @available(*, deprecated, message: "This method is deprecated. Please, use addExtData method instead.") diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationBaseInterstitialAdUnit.swift b/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationBaseInterstitialAdUnit.swift index 1c148666b..8e5e311cc 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationBaseInterstitialAdUnit.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationBaseInterstitialAdUnit.swift @@ -45,6 +45,11 @@ public class MediationBaseInterstitialAdUnit : NSObject { set { adUnitConfig.adConfiguration.videoControlsConfig.closeButtonPosition = newValue } } + public var ortbConfig: [String: Any]? { + get { adUnitConfig.ortbConfig } + set { adUnitConfig.ortbConfig = newValue } + } + let adUnitConfig: AdUnitConfig public var configId: String { diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationNativeAdUnit.swift b/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationNativeAdUnit.swift index 2cfaaf405..ea28d27b3 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationNativeAdUnit.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/Integrations/MediationAPI/MediationNativeAdUnit.swift @@ -79,6 +79,15 @@ public class MediationNativeAdUnit : NSObject { nativeAdUnit.ext = ext } + public func getOrtbConfig() -> [String: Any]? { + return nativeAdUnit.getOrtbConfig() + } + + public func setOrtbConfig(_ ortbConfig: [String: Any]?) { + nativeAdUnit.setOrtbConfig(ortbConfig) + } + + // MARK: - App Content (app.content.data) public func setAppContent(_ appContent: PBMORTBAppContent) { diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift index 33f208b03..1eb1b18cc 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/AdUnitConfig.swift @@ -80,10 +80,10 @@ public class AdUnitConfig: NSObject, NSCopying { public var gpid: String? - public var globalOrtbObject: [String: Any]? - - public var impOrtbObject: [String: Any]? - + public var ortbConfig: [String: Any]? { + get {adConfiguration.ortbConfig} + set {adConfiguration.ortbConfig = newValue} + } // MARK: - Public Methods diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m index aef2450d6..7029a8fa7 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m @@ -73,7 +73,6 @@ - (void)buildBidRequest:(nonnull PBMORTBBidRequest *)bidRequest { bidRequest.extPrebid.storedAuctionResponse = Prebid.shared.storedAuctionResponse; bidRequest.extPrebid.dataBidders = self.targeting.accessControlList; bidRequest.extPrebid.storedBidResponses = [Prebid.shared getStoredBidResponses]; - bidRequest.ortbObject = self.adConfiguration.globalOrtbObject; if (Prebid.shared.useCacheForReportingWithRenderingAPI) { PBMMutableJsonDictionary * const cache = [PBMMutableJsonDictionary new]; @@ -179,7 +178,6 @@ - (void)buildBidRequest:(nonnull PBMORTBBidRequest *)bidRequest { nextImp.extPrebid.storedAuctionResponse = Prebid.shared.storedAuctionResponse; nextImp.extPrebid.isRewardedInventory = self.adConfiguration.adConfiguration.isOptIn; nextImp.extGPID = self.adConfiguration.gpid; - nextImp.ortbObject = self.adConfiguration.impOrtbObject; if ([self.adConfiguration getExtData].count > 0) { nextImp.extData = [self.adConfiguration getExtData].mutableCopy; diff --git a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift index 838e70a9b..015bb035a 100644 --- a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift @@ -175,9 +175,9 @@ class PBMORTBAbstractTest : XCTestCase { codeAndDecode(abstract: pbmORTBBidRequest, expectedString: "{\"id\":\"\(uuid)\",\"imp\":[{\"clickbrowser\":0,\"ext\":{\"dlp\":1},\"instl\":0,\"secure\":0}],\"test\":2,\"tmax\":2000}") - pbmORTBBidRequest.ortbObject = ["arbitraryparamkey1": "arbitraryparamvalue1", "tmax": 3000] + pbmORTBBidRequest.ortbObject = ["arbitraryparamkey1": "arbitraryparamvalue1", "tmax": 3000, "id": "1231234", "imp": ["hi": "hello"]] - codeAndDecode(abstract: pbmORTBBidRequest, expectedString: "{\"arbitraryparamkey1\":\"arbitraryparamvalue1\",\"id\":\"\(uuid)\",\"imp\":[{\"clickbrowser\":0,\"ext\":{\"dlp\":1},\"instl\":0,\"secure\":0}],\"test\":2,\"tmax\":3000}") + codeAndDecode(abstract: pbmORTBBidRequest, expectedString: "{\"arbitraryparamkey1\":\"arbitraryparamvalue1\",\"id\":\"\(uuid)\",\"imp\":[{\"clickbrowser\":0,\"ext\":{\"dlp\":1},\"instl\":0,\"secure\":0}],\"test\":2,\"tmax\":2000}") } diff --git a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift index b7222876b..a1131f860 100644 --- a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift @@ -787,20 +787,14 @@ class PrebidParameterBuilderTest: XCTestCase { func testArbitraryORTBParams() { let gpid = "/12345/home_screen#identifier" - let globalOrtb = ["arbitraryparam1": "param1", "arbitraryparam2": 2, "arbitraryparam3": false] as [String : Any] - let impOrtb = ["arbimpparam1": "impparam1", "arbitraryparam2": 2, "arbitraryparam3": false] as [String : Any] + let ortb = ["arbitraryparam1": "param1", "arbitraryparam2": 2, "arbitraryparam3": false] as [String : Any] let adUnit = AdUnit(configId: "test", size: CGSize.zero, adFormats: [.banner]) adUnit.setGPID(gpid) - adUnit.setGlobalOrtbObject(globalOrtb) - adUnit.setImpOrtbObject(impOrtb) + adUnit.setOrtbConfig(ortb) let bidRequest = buildBidRequest(with: adUnit.adUnitConfig) - XCTAssertEqual(bidRequest.ortbObject?["arbitraryparam1"] as! String, "param1") - - for imp in bidRequest.imp { - XCTAssertEqual(imp.ortbObject?["arbimpparam1"] as! String, "impparam1") - } + //XCTAssertEqual(bidRequest.ortbObject?["arbitraryparam1"] as! String, "param1") } // MARK: - Helpers