Skip to content

Commit

Permalink
release 7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliy-pavlenko committed Sep 12, 2024
1 parent b23351f commit 1b52fce
Show file tree
Hide file tree
Showing 39 changed files with 307 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Criteo Publisher SDK Changelog
--------------------------------------------------------------------------------
## Version [7.0.0]

### Features
- Add InventoryGroupId parameter, update register method

--------------------------------------------------------------------------------
## Version [6.2.0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class AdViewerViewController: FormViewController {
Criteo.resetSharedCriteo()
let criteo = Criteo.shared()
criteo.networkManagerDelegate = LogManager.sharedInstance()
criteo.registerPublisherId(publisherId, withStoreId: "testStoreid", with: adUnits)
criteo.registerPublisherId(publisherId, withInventoryGroupId: "someId", withStoreId: "testStoreid", with: adUnits)
return criteo
}

Expand Down
2 changes: 1 addition & 1 deletion CriteoAdViewer/Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>6.2.0</string>
<string>7.0.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand Down
2 changes: 1 addition & 1 deletion CriteoAdViewer/UITests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>6.2.0</string>
<string>7.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ @implementation CRBannerCustomEvent
- (void)loadBannerForAdUnit:(CRBannerAdUnit *)adUnit
mediationParams:(CRGoogleMediationParameters *)params
childDirectedTreatment:(NSNumber *)childDirectedTreatment {
/// Set the publicher id to
/// Set the publisher id to
[Criteo.sharedCriteo registerCriteoPublisherId:params.publisherId
withInventoryGroupId:params.inventoryGroupId
withStoreId:params.storeId
withAdUnits:@[ adUnit ]];
/// Set child directed treatment flag to Criteo SDK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ NS_ASSUME_NONNULL_BEGIN

- (instancetype)init NS_UNAVAILABLE;
- (id)initWithPublisherId:(NSString *)publisherId
inventoryGroupId:(NSString *)inventoryGroupId
storeId:(NSString *)storeId
adUnitId:(NSString *)adUnitId;
+ (nullable CRGoogleMediationParameters *)parametersFromJSONString:(NSString *)jsonString
Expand All @@ -33,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(copy, readonly) NSString *publisherId;
@property(copy, readonly) NSString *adUnitId;
@property(copy, readonly) NSString *storeId;
@property(copy, nullable, readonly) NSString *inventoryGroupId;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
static NSString *const criteoGoogleMediationPublisherIdKey = @"cpId";
static NSString *const criteoGoogleMediationAdUnitIdKey = @"adUnitId";
static NSString *const criteoGoogleMediationStoreIdKey = @"storeId";
static NSString *const criteoGoogleMediationInventoryGroupIdKey = @"inventoryGroupId";

static void setJSONParsingError(NSError **error) {
if (error != nil) {
Expand All @@ -44,6 +45,7 @@ static void setJSONParsingError(NSError **error) {
@implementation CRGoogleMediationParameters

- (id)initWithPublisherId:(NSString *)publisherId
inventoryGroupId:(NSString *)inventoryGroupId
storeId:(NSString *)storeId
adUnitId:(NSString *)adUnitId {
self = [super init];
Expand All @@ -53,6 +55,9 @@ - (id)initWithPublisherId:(NSString *)publisherId
_publisherId = [NSString stringWithString:publisherId];
_adUnitId = [NSString stringWithString:adUnitId];
_storeId = [NSString stringWithString:storeId];
if (inventoryGroupId != nil) {
_inventoryGroupId = [NSString stringWithString:inventoryGroupId];
}
return self;
}

Expand All @@ -75,6 +80,8 @@ + (nullable CRGoogleMediationParameters *)parametersFromJSONString:(NSString *)j
NSString *pubId = nonEmptyStringFromObj(jsonDict[criteoGoogleMediationPublisherIdKey]);
NSString *adId = nonEmptyStringFromObj(jsonDict[criteoGoogleMediationAdUnitIdKey]);
NSString *storeId = nonEmptyStringFromObj(jsonDict[criteoGoogleMediationStoreIdKey]);
NSString *inventoryGroupId =
nonEmptyStringFromObj(jsonDict[criteoGoogleMediationInventoryGroupIdKey]);
if (pubId == nil || adId == nil) {
setJSONParsingError(error);
return nil;
Expand All @@ -83,6 +90,7 @@ + (nullable CRGoogleMediationParameters *)parametersFromJSONString:(NSString *)j
*error = nil;
}
return [[CRGoogleMediationParameters alloc] initWithPublisherId:pubId
inventoryGroupId:inventoryGroupId
storeId:storeId
adUnitId:adId];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ - (void)loadInterstitialForAdUnit:(CRInterstitialAdUnit *)adUnit
adConfiguration:(CRGoogleMediationParameters *)params
childDirectedTreatment:(NSNumber *)childDirectedTreatment {
[Criteo.sharedCriteo registerCriteoPublisherId:params.publisherId
withInventoryGroupId:params.inventoryGroupId
withStoreId:params.storeId
withAdUnits:@[ adUnit ]];
/// Set child directed treatment flag to Criteo SDK.
Expand Down
2 changes: 1 addition & 1 deletion CriteoGoogleAdapter/Sources/CriteoGoogleAdapter/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>6.2.0</string>
<string>7.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ - (instancetype)initWithBanner:(CRBannerView *)ad {
#define SERVER_PARAMETER \
@"{\"cpId\":\"testCpId\",\"adUnitId\":\"testAdUnitId\",\"storeId\":\"testStoreId\"}"

#define SERVER_PARAMETER_WITH_INVENTORY_GROUP_ID \
@"{\"cpId\":\"testCpId\",\"inventoryGroupId\":\"testInventoryGroupId\",\"adUnitId\":\"testAdUnitId\",\"storeId\":\"testStoreId\"}"

@implementation CRBannerCustomEventTests

- (void)testRequestBannerAdSuccess {
Expand All @@ -71,6 +74,41 @@ - (void)testRequestBannerAdSuccess {
id mockCriteo = OCMClassMock([Criteo class]);
OCMStub([mockCriteo sharedCriteo]).andReturn(mockCriteo);
OCMStub([mockCriteo registerCriteoPublisherId:@"testCpId"
withInventoryGroupId:nil
withStoreId:@"testStoreId"
withAdUnits:@[ bannerAdUnit ]]);
OCMStub([mockCriteo setChildDirectedTreatment:mockChildDirectedTreatment]);

[customEvent loadBannerForAdUnit:bannerAdUnit
mediationParams:params
childDirectedTreatment:mockChildDirectedTreatment];

OCMVerify([mockCRBannerView loadAd]);
OCMVerify([mockCRBannerView setDelegate:customEvent]);
OCMVerify([mockCriteo registerCriteoPublisherId:@"testCpId"
withInventoryGroupId:nil
withStoreId:@"testStoreId"
withAdUnits:@[ bannerAdUnit ]]);
OCMVerify([mockCriteo setChildDirectedTreatment:mockChildDirectedTreatment]);
}

- (void)testRequestBannerAdSuccessWithInventoryGroupId {
NSNumber *mockChildDirectedTreatment = @YES;
CRBannerView *mockCRBannerView = OCMStrictClassMock([CRBannerView class]);
CRBannerAdUnit *bannerAdUnit = [[CRBannerAdUnit alloc] initWithAdUnitId:@"testAdUnitId"
size:CGSizeMake(320, 50)];
CRBannerCustomEvent *customEvent = [[CRBannerCustomEvent alloc] initWithBanner:mockCRBannerView];
CRGoogleMediationParameters *params =
[CRGoogleMediationParameters parametersFromJSONString:SERVER_PARAMETER_WITH_INVENTORY_GROUP_ID
error:NULL];

OCMStub([mockCRBannerView loadAd]);
OCMStub([mockCRBannerView setDelegate:customEvent]);

id mockCriteo = OCMClassMock([Criteo class]);
OCMStub([mockCriteo sharedCriteo]).andReturn(mockCriteo);
OCMStub([mockCriteo registerCriteoPublisherId:@"testCpId"
withInventoryGroupId:@"testInventoryGroupId"
withStoreId:@"testStoreId"
withAdUnits:@[ bannerAdUnit ]]);
OCMStub([mockCriteo setChildDirectedTreatment:mockChildDirectedTreatment]);
Expand All @@ -82,6 +120,7 @@ - (void)testRequestBannerAdSuccess {
OCMVerify([mockCRBannerView loadAd]);
OCMVerify([mockCRBannerView setDelegate:customEvent]);
OCMVerify([mockCriteo registerCriteoPublisherId:@"testCpId"
withInventoryGroupId:@"testInventoryGroupId"
withStoreId:@"testStoreId"
withAdUnits:@[ bannerAdUnit ]]);
OCMVerify([mockCriteo setChildDirectedTreatment:mockChildDirectedTreatment]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ - (void)testGoogleMediationParametersNormal {
NSError *error;
CRGoogleMediationParameters *gmp = [CRGoogleMediationParameters
parametersFromJSONString:
@"{\"cpId\":\"B-056946\", \"adUnitId\": \"/140800857/Endeavour_320x50\", \"storeId\": \"B-056946\"}"
@"{\"cpId\":\"B-056946\", \"inventoryGroupId\":\"testInventoryGroupId\", \"adUnitId\": \"/140800857/Endeavour_320x50\", \"storeId\": \"B-056946\"}"
error:&error];
XCTAssertNotNil(gmp);
XCTAssertEqualObjects(gmp.publisherId, @"B-056946");
XCTAssertEqualObjects(gmp.inventoryGroupId, @"testInventoryGroupId");
XCTAssertEqualObjects(gmp.adUnitId, @"/140800857/Endeavour_320x50");
XCTAssertEqualObjects(gmp.storeId, @"B-056946");
}
Expand All @@ -42,7 +43,7 @@ - (void)testGoogleMediationParametersErrorSetToNil {
NSError *error = [NSError new];
CRGoogleMediationParameters *gmp = [CRGoogleMediationParameters
parametersFromJSONString:
@"{\"cpId\":\"B-056946\", \"adUnitId\": \"/140800857/Endeavour_320x50\", \"storeId\": \"B-056946\"}"
@"{\"cpId\":\"B-056946\", \"inventoryGroupId\":\"testInventoryGroupId\", \"adUnitId\": \"/140800857/Endeavour_320x50\", \"storeId\": \"B-056946\"}"
error:&error];
XCTAssertNil(error);
}
Expand All @@ -51,10 +52,11 @@ - (void)testGoogleMediationParametersErrorSetToNil {
- (void)testGoogleMediationParametersNilError {
CRGoogleMediationParameters *gmp = [CRGoogleMediationParameters
parametersFromJSONString:
@"{\"cpId\":\"B-056946\", \"adUnitId\": \"/140800857/Endeavour_320x50\", \"storeId\": \"B-056946\"}"
@"{\"cpId\":\"B-056946\", \"inventoryGroupId\":\"testInventoryGroupId\", \"adUnitId\": \"/140800857/Endeavour_320x50\", \"storeId\": \"B-056946\"}"
error:nil];
XCTAssertNotNil(gmp);
XCTAssertEqualObjects(gmp.publisherId, @"B-056946");
XCTAssertEqualObjects(gmp.inventoryGroupId, @"testInventoryGroupId");
XCTAssertEqualObjects(gmp.adUnitId, @"/140800857/Endeavour_320x50");
XCTAssertEqualObjects(gmp.storeId, @"B-056946");
}
Expand Down Expand Up @@ -148,4 +150,43 @@ - (void)testGoogleMediationParametersTotallyBadJson {
XCTAssertEqual(error.code, GADErrorInvalidArgument);
}

// Blank inventoryGroupId
- (void)testGoogleMediationParametersBlankInventoryGroupId {
NSError *error;
CRGoogleMediationParameters *gmp = [CRGoogleMediationParameters
parametersFromJSONString:
@"{\"cpId\":\"B-056946\", \"inventoryGroupId\":\"\", \"adUnitId\": \"/140800857/Endeavour_320x50\", \"storeId\": \"B-056946\"}"
error:&error];
XCTAssertNotNil(gmp);
XCTAssertEqualObjects(gmp.publisherId, @"B-056946");
XCTAssertNil(gmp.inventoryGroupId);
XCTAssertEqualObjects(gmp.adUnitId, @"/140800857/Endeavour_320x50");
XCTAssertEqualObjects(gmp.storeId, @"B-056946");
}

// Nil inventoryGroupId
- (void)testGoogleMediationParametersNilInventoryGroupId {
NSError *error;
CRGoogleMediationParameters *gmp = [CRGoogleMediationParameters
parametersFromJSONString:
@"{\"cpId\":\"B-056946\", \"adUnitId\": \"/140800857/Endeavour_320x50\", \"storeId\": \"B-056946\"}"
error:&error];
XCTAssertNotNil(gmp);
XCTAssertEqualObjects(gmp.publisherId, @"B-056946");
XCTAssertNil(gmp.inventoryGroupId);
XCTAssertEqualObjects(gmp.adUnitId, @"/140800857/Endeavour_320x50");
XCTAssertEqualObjects(gmp.storeId, @"B-056946");
}

// Non-string inventoryGroupId
- (void)testGoogleMediationParametersNonStringInventoryGroupId {
NSError *error = [NSError new];
CRGoogleMediationParameters *gmp = [CRGoogleMediationParameters
parametersFromJSONString:
@"{\"cpId\":\"B-056946\", \"inventoryGroupId\":1, \"adUnitID\": \"/140800857/Endeavour_320x50\", \"storeId\": \"B-056946\"}"
error:&error];
XCTAssertNil(gmp);
XCTAssertEqual(error.code, GADErrorInvalidArgument);
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ - (instancetype)initWithInterstitial:(CRInterstitial *)interstitial {
#define SERVER_PARAMETER \
@"{\"cpId\":\"testCpId\",\"adUnitId\":\"testAdUnitId\",\"storeId\":\"testStoreId\"}"

#define SERVER_PARAMETER_WITH_INVENTORY_GROUP_ID \
@"{\"cpId\":\"testCpId\",\"inventoryGroupId\":\"testInventoryGroupId\",\"adUnitId\":\"testAdUnitId\",\"storeId\":\"testStoreId\"}"

@implementation CRInterstitialCustomEventTests

- (void)testLoadAndPresentFromRootViewController {
Expand All @@ -78,6 +81,46 @@ - (void)testLoadAndPresentFromRootViewController {
id mockCriteo = OCMStrictClassMock([Criteo class]);
OCMStub([mockCriteo sharedCriteo]).andReturn(mockCriteo);
OCMStub([mockCriteo registerCriteoPublisherId:@"testCpId"
withInventoryGroupId:nil
withStoreId:@"testStoreId"
withAdUnits:@[ interstitialAdUnit ]]);
OCMStub([mockCriteo setChildDirectedTreatment:mockChildDirectedTreatment]);

[customEvent loadInterstitialForAdUnit:interstitialAdUnit
adConfiguration:params
childDirectedTreatment:mockChildDirectedTreatment];
[customEvent presentFromViewController:realVC];

OCMVerify([mockCRInterstitial loadAd]);
OCMVerify([mockCRInterstitial setDelegate:customEvent]);
OCMVerify([mockCRInterstitial presentFromRootViewController:realVC]);
OCMVerify([mockCriteo registerCriteoPublisherId:@"testCpId"
withInventoryGroupId:nil
withStoreId:@"testStoreId"
withAdUnits:@[ interstitialAdUnit ]]);
OCMVerify([mockCriteo setChildDirectedTreatment:mockChildDirectedTreatment]);
}

- (void)testLoadAndPresentFromRootViewControllerWithInventoryGroupId {
NSNumber *mockChildDirectedTreatment = @YES;
CRInterstitial *mockCRInterstitial = OCMStrictClassMock([CRInterstitial class]);
CRInterstitialAdUnit *interstitialAdUnit =
[[CRInterstitialAdUnit alloc] initWithAdUnitId:@"testAdUnitId"];
CRInterstitialCustomEvent *customEvent =
[[CRInterstitialCustomEvent alloc] initWithInterstitial:mockCRInterstitial];
CRGoogleMediationParameters *params =
[CRGoogleMediationParameters parametersFromJSONString:SERVER_PARAMETER_WITH_INVENTORY_GROUP_ID
error:NULL];
OCMStub([mockCRInterstitial loadAd]);
OCMStub([mockCRInterstitial setDelegate:customEvent]);
UIViewController *realVC = [UIViewController new];
OCMStub([mockCRInterstitial presentFromRootViewController:realVC]);
OCMStub([mockCRInterstitial isAdLoaded]).andReturn(YES);

id mockCriteo = OCMStrictClassMock([Criteo class]);
OCMStub([mockCriteo sharedCriteo]).andReturn(mockCriteo);
OCMStub([mockCriteo registerCriteoPublisherId:@"testCpId"
withInventoryGroupId:@"testInventoryGroupId"
withStoreId:@"testStoreId"
withAdUnits:@[ interstitialAdUnit ]]);
OCMStub([mockCriteo setChildDirectedTreatment:mockChildDirectedTreatment]);
Expand All @@ -91,6 +134,7 @@ - (void)testLoadAndPresentFromRootViewController {
OCMVerify([mockCRInterstitial setDelegate:customEvent]);
OCMVerify([mockCRInterstitial presentFromRootViewController:realVC]);
OCMVerify([mockCriteo registerCriteoPublisherId:@"testCpId"
withInventoryGroupId:@"testInventoryGroupId"
withStoreId:@"testStoreId"
withAdUnits:@[ interstitialAdUnit ]]);
OCMVerify([mockCriteo setChildDirectedTreatment:mockChildDirectedTreatment]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>6.2.0</string>
<string>7.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion CriteoPublisherSdk.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "CriteoPublisherSdk"
spec.version = "6.2.0"
spec.version = "7.0.0"
spec.summary = "Criteo Publisher SDK for iOS"

spec.description = <<-DESC
Expand Down
6 changes: 6 additions & 0 deletions CriteoPublisherSdk/Sources/Configuration/CR_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ FOUNDATION_EXTERN NSString *const CR_ConfigConfigurationUrl;
#pragma mark - Properties

@property(copy, nonatomic, nullable) NSString *criteoPublisherId;
@property(copy, nonatomic, nullable) NSString *inventoryGroupId;
@property(assign, nonatomic) BOOL killSwitch;
@property(copy, nonatomic) NSString *adTagUrlMode;
@property(copy, nonatomic) NSString *viewportWidthMacro;
Expand Down Expand Up @@ -79,15 +80,20 @@ FOUNDATION_EXTERN NSString *const CR_ConfigConfigurationUrl;
#pragma mark - Lifecycle

- (instancetype)initWithCriteoPublisherId:(nullable NSString *)criteoPublisherId
inventoryGroupId:(nullable NSString *)inventoryGroupId
storeId:(nullable NSString *)storeId
cdbUrl:(NSString *)cdbUrl
appEventsUrl:(NSString *)appEventsUrl
configUrl:(NSString *)configUrl
userDefaults:(NSUserDefaults *)userDefaults NS_DESIGNATED_INITIALIZER;

- (instancetype)initWithCriteoPublisherId:(nullable NSString *)criteoPublisherId
inventoryGroupId:(nullable NSString *)inventoryGroupId
storeId:(nullable NSString *)storeId;

- (instancetype)initWithCriteoPublisherId:(nullable NSString *)criteoPublisherId
inventoryGroupId:(nullable NSString *)inventoryGroupId;

- (instancetype)initWithCriteoPublisherId:(nullable NSString *)criteoPublisherId;

- (instancetype)initWithUserDefaults:(NSUserDefaults *)userDefaults;
Expand Down
Loading

0 comments on commit 1b52fce

Please sign in to comment.