From d16bd3b4baee50b7789e717c014f47df9f4dcdb5 Mon Sep 17 00:00:00 2001 From: Vincent Guerci Date: Thu, 18 Jun 2020 16:53:35 +0200 Subject: [PATCH] Bump Publisher SDK version to 3.7.0 --- CHANGELOG.md | 2 +- CRCriteoAdapterConfiguration.m | 4 ++-- CRCustomEventHelper.h | 8 ++++++- CRCustomEventHelper.m | 40 ++++++++++++++++++++++++++-------- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a764f7..1855efc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Criteo MoPub Mediation Adapters Changelog -------------------------------------------------------------------------------- Note: Adapters are updated to follow Criteo Publisher SDK versions. - i.e. v3.6.1.0 adapters target a SDK with minimum v3.6.1 + i.e. v3.6.1.0 adapters target a SDK with minimum v3.6.1 Unless the adapters themselves are modified, this won't be reflected in this changelog. -------------------------------------------------------------------------------- ## Version 3.4.1.0 diff --git a/CRCriteoAdapterConfiguration.m b/CRCriteoAdapterConfiguration.m index 8ad2f3b..933083a 100644 --- a/CRCriteoAdapterConfiguration.m +++ b/CRCriteoAdapterConfiguration.m @@ -24,7 +24,7 @@ - (NSString *)adapterVersion { // We use an hardcoded value (not a macro) so // that the file is self-contained in the // open-source repository. - return @"3.6.1.0"; + return @"3.7.0.0"; } - (NSString *)biddingToken { @@ -36,7 +36,7 @@ - (NSString *)moPubNetworkName{ } - (NSString *)networkSdkVersion { - return @"3.6.1.0"; + return @"3.7.0.0"; } - (void)initializeNetworkWithConfiguration:(NSDictionary *)configuration complete:(void(^)(NSError *))complete { diff --git a/CRCustomEventHelper.h b/CRCustomEventHelper.h index 280d111..1838b5a 100644 --- a/CRCustomEventHelper.h +++ b/CRCustomEventHelper.h @@ -20,9 +20,15 @@ NS_ASSUME_NONNULL_BEGIN +extern NSString * const kCRCustomEventHelperCpId; +extern NSString * const kCRCustomEventHelperAdUnitId; + @interface CRCustomEventHelper : NSObject -+ (BOOL) checkValidInfo:(NSDictionary *)info; ++ (BOOL)checkValidInfo:(NSDictionary *)info; + ++ (BOOL)checkValidInfo:(NSDictionary *)eventInfo + withError:(NSError **)error; @end diff --git a/CRCustomEventHelper.m b/CRCustomEventHelper.m index ed30828..3ae727f 100644 --- a/CRCustomEventHelper.m +++ b/CRCustomEventHelper.m @@ -17,21 +17,43 @@ // limitations under the License. #import "CRCustomEventHelper.h" +#import "MPNativeAdError.h" -NSString * const cpId = @"cpId"; -NSString * const adUnitId = @"adUnitId"; +NSString * const kCRCustomEventHelperCpId = @"cpId"; +NSString * const kCRCustomEventHelperAdUnitId = @"adUnitId"; @implementation CRCustomEventHelper -+ (BOOL) checkValidInfo:(NSDictionary *)info { - if (info){ - if ([info[cpId] isKindOfClass:NSString.class] && [info[adUnitId] isKindOfClass:NSString.class]){ - if ([info[cpId] length] > 0 && [info[adUnitId] length] > 0){ - return YES; - } ++ (BOOL)checkValidInfo:(NSDictionary *)info { + return [self checkValidInfo:info + withError:nil]; +} + ++ (BOOL)checkValidInfo:(NSDictionary *)eventInfo + withError:(NSError **)error { + NSArray *expectedKeys = @[ + kCRCustomEventHelperCpId, + kCRCustomEventHelperAdUnitId + ]; + NSMutableString *errorMsg = [[NSMutableString alloc] init]; + BOOL isValid = YES; + for (NSString *key in expectedKeys) { + NSString *value = eventInfo[key]; + if (![value isKindOfClass:NSString.class] || + (value.length == 0)) { + isValid = NO; + NSString *str = [[NSString alloc] initWithFormat: + @"The Criteo '%@' key is missing or invalid. ", + key]; + [errorMsg appendString:str]; } } - return NO; + if (!isValid && (error != nil)) { + [errorMsg appendString:@"No ad request sent. " + "Ensure this key is valid on the MoPub dashboard."]; + *error = MPNativeAdNSErrorForInvalidAdServerResponse(errorMsg); + } + return isValid; } @end