From 31add3c5b659233f94e503bbc63a81c5e8ae64ba Mon Sep 17 00:00:00 2001 From: sfukui66 Date: Wed, 30 Aug 2023 15:38:53 +0900 Subject: [PATCH 1/2] Update MaioAdapter version: 2.0.0.0 --- Maio/AppLovinMediationMaioAdapter.podspec | 4 +- Maio/MaioAdapter/ALMaioMediationAdapter.m | 542 +++++++++------------- 2 files changed, 234 insertions(+), 312 deletions(-) diff --git a/Maio/AppLovinMediationMaioAdapter.podspec b/Maio/AppLovinMediationMaioAdapter.podspec index bd4b791653..c8206b1cec 100644 --- a/Maio/AppLovinMediationMaioAdapter.podspec +++ b/Maio/AppLovinMediationMaioAdapter.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.authors = 'AppLovin Corporation' s.name = 'AppLovinMediationMaioAdapter' -s.version = '1.6.3.3' +s.version = '2.0.0.0' s.platform = :ios, '9.0' s.summary = 'Maio adapter used for mediation with the AppLovin MAX SDK' s.homepage = "https://github.com/CocoaPods/Specs/search?o=desc&q=#{s.name}&s=indexed" @@ -26,7 +26,7 @@ s.source = s.vendored_frameworks = "#{s.name}-#{s.version}/#{s.name}.xcframework" -s.dependency 'MaioSDK', '= 1.6.3' +s.dependency 'MaioSDK-v2', '= 2.0.0' s.dependency 'AppLovinSDK' s.description = <<-DESC diff --git a/Maio/MaioAdapter/ALMaioMediationAdapter.m b/Maio/MaioAdapter/ALMaioMediationAdapter.m index b6e92ae882..23bee23235 100644 --- a/Maio/MaioAdapter/ALMaioMediationAdapter.m +++ b/Maio/MaioAdapter/ALMaioMediationAdapter.m @@ -7,96 +7,48 @@ // #import "ALMaioMediationAdapter.h" -#import -#import +#import -#define ADAPTER_VERSION @"1.6.3.3" +#define ADAPTER_VERSION @"2.0.0.0" -@interface ALMaioMediationAdapterRouter : ALMediationAdapterRouter - -@property (nonatomic, strong) ALAtomicBoolean *isShowingAd; -@property (nonatomic, assign, getter=hasGrantedReward) BOOL grantedReward; - -@property (nonatomic, copy, nullable) void(^oldCompletionHandler)(void); -@property (nonatomic, copy, nullable) void(^newCompletionHandler)(MAAdapterInitializationStatus, NSString *_Nullable); +@interface ALMaioMediationAdapterInterstitialAdDelegate : NSObject +@property (nonatomic, weak) ALMaioMediationAdapter *parentAdapter; +@property (nonatomic, strong) id delegate; +- (instancetype)initWithParentAdapter:(ALMaioMediationAdapter *)parentAdapter andNotify:(id)delegate; +@end +@interface ALMaioMediationAdapterRewardedAdDelegate : NSObject +@property (nonatomic, weak) ALMaioMediationAdapter *parentAdapter; +@property (nonatomic, strong) id delegate; +- (instancetype)initWithParentAdapter:(ALMaioMediationAdapter *)parentAdapter andNotify:(id)delegate; @end @interface ALMaioMediationAdapter () -@property (nonatomic, strong, readonly) ALMaioMediationAdapterRouter *router; -@property (nonatomic, copy) NSString *zoneId; +@property (nonatomic) BOOL isTesting; +@property (nonatomic, strong) MaioInterstitial *maioInterstitial; +@property (nonatomic, strong) MaioRewarded *maioRewarded; + +@property (nonatomic, strong) ALMaioMediationAdapterInterstitialAdDelegate *interstitialAdapterDelegate; +@property (nonatomic, strong) ALMaioMediationAdapterRewardedAdDelegate *rewardedAdapterDelegate; @end @implementation ALMaioMediationAdapter -@dynamic router; - -static ALAtomicBoolean *ALMaioInitialized; -static MAAdapterInitializationStatus ALMaioIntializationStatus = NSIntegerMin; - -+ (void)initialize -{ - [super initialize]; - - ALMaioInitialized = [[ALAtomicBoolean alloc] init]; -} #pragma mark - MAAdapter Methods -- (void)initializeWithParameters:(id)parameters withCompletionHandler:(void (^)(void))completionHandler +- (void)initializeWithParameters:(id)parameters completionHandler:(void(^)(MAAdapterInitializationStatus, NSString *_Nullable))completionHandler { - if ( [ALMaioInitialized compareAndSet: NO update: YES] ) - { - NSString *mediaId = [parameters.serverParameters al_stringForKey: @"media_id"]; - - [self log: @"Initializing Maio with media id: %@", mediaId]; - - if ( [parameters isTesting] ) - { - [Maio setAdTestMode: YES]; - } - - self.router.oldCompletionHandler = completionHandler; - - [Maio startWithMediaId: mediaId delegate: self.router]; - } - else - { - [self log: @"Maio already initialized"]; - completionHandler(); - } -} + self.isTesting = parameters.isTesting; -- (void)initializeWithParameters:(id)parameters - completionHandler:(void(^)(MAAdapterInitializationStatus initializationStatus, NSString *_Nullable errorMessage))completionHandler -{ - if ( [ALMaioInitialized compareAndSet: NO update: YES] ) - { - NSString *mediaId = [parameters.serverParameters al_stringForKey: @"media_id"]; - - [self log: @"Initializing Maio with media id: %@", mediaId]; - - if ( [parameters isTesting] ) - { - [Maio setAdTestMode: YES]; - } - - self.router.newCompletionHandler = completionHandler; - ALMaioIntializationStatus = MAAdapterInitializationStatusInitializing; - - [Maio startWithMediaId: mediaId delegate: self.router]; - } - else - { - [self log: @"Maio already initialized"]; - completionHandler(ALMaioIntializationStatus, nil); - } + // Maio SDK does not have any API for initialization. + completionHandler(MAAdapterInitializationStatusDoesNotApply, nil); } - (NSString *)SDKVersion { - return [Maio sdkVersion]; + return [[MaioVersion shared] toString]; } - (NSString *)adapterVersion @@ -106,39 +58,35 @@ - (NSString *)adapterVersion - (void)destroy { - [self.router removeAdapter: self forPlacementIdentifier: self.zoneId]; + [self log: @"Destroy called for adapter: %@", self]; + + self.maioInterstitial = nil; + self.interstitialAdapterDelegate.delegate = nil; + self.interstitialAdapterDelegate = nil; + + self.maioRewarded = nil; + self.rewardedAdapterDelegate.delegate = nil; + self.rewardedAdapterDelegate = nil; } -#pragma mark - MAInterstitialAdapterMethods +#pragma mark - MAInterstitialAdapter Methods -- (void)loadInterstitialAdForParameters:(id)parameters andNotify:(id)delegate +- (void)loadInterstitialAdForParameters:(nonnull id)parameters andNotify:(nonnull id)delegate { - self.zoneId = parameters.thirdPartyAdPlacementIdentifier; - - [self log: @"Loading interstitial ad: %@...", self.zoneId]; - - [self.router addInterstitialAdapter: self delegate: delegate forPlacementIdentifier: self.zoneId]; - - // `canShowAtZoneId:` will callback to `maioDidFail:reason:` with `MaioFailReasonIncorrectZoneId` - Android does not (hence extra check) - if ( [Maio canShowAtZoneId: self.zoneId] ) - { - [self.router didLoadAdForPlacementIdentifier: self.zoneId]; - } - // Maio might lose out on the first impression. - else - { - [self log: @"Ad failed to load for this zone: %@", self.zoneId]; - [self.router didFailToLoadAdForPlacementIdentifier: self.zoneId error: MAAdapterError.noFill]; - } + NSString *zoneID = parameters.thirdPartyAdPlacementIdentifier; + [self log: @"Loading interstitial ad: %@...", zoneID]; + + self.interstitialAdapterDelegate = [[ALMaioMediationAdapterInterstitialAdDelegate alloc] initWithParentAdapter:self andNotify:delegate]; + + MaioRequest *request = [[MaioRequest alloc] initWithZoneId:zoneID testMode:self.isTesting]; + self.maioInterstitial = [MaioInterstitial loadAdWithRequest:request callback:self.interstitialAdapterDelegate]; } -- (void)showInterstitialAdForParameters:(id)parameters andNotify:(id)delegate +- (void)showInterstitialAdForParameters:(nonnull id)parameters andNotify:(nonnull id)delegate { - [self log: @"Showing interstitial ad %@", self.zoneId]; - - [self.router addShowingAdapter: self]; - - if ( [Maio canShowAtZoneId: self.zoneId] ) + [self log: @"Showing interstitial ad..."]; + + if ( self.maioInterstitial != nil ) { UIViewController *presentingViewController; if ( ALSdk.versionCode >= 11020199 ) @@ -149,56 +97,39 @@ - (void)showInterstitialAdForParameters:(id)paramet { presentingViewController = [ALUtils topViewControllerFromKeyWindow]; } - - [Maio showAtZoneId: self.zoneId vc: presentingViewController]; + + [self.maioInterstitial showWithViewContext:presentingViewController callback:self.interstitialAdapterDelegate]; } else { - [self log: @"Interstitial not ready"]; - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self.router didFailToDisplayAdForPlacementIdentifier: self.zoneId error: [MAAdapterError errorWithCode: -4205 - errorString: @"Ad Display Failed" - thirdPartySdkErrorCode: 0 - thirdPartySdkErrorMessage: @"Interstitial ad not ready"]]; -#pragma clang diagnostic pop + [self log: @"Interstitial ad not ready"]; + + [delegate didFailToDisplayInterstitialAdWithError:[MAAdapterError errorWithCode:-4205 + errorString:@"Ad Display Failed" + mediatedNetworkErrorCode:0 + mediatedNetworkErrorMessage:@"Interstitial ad not ready"]]; } } #pragma mark - MARewardedAdapter Methods -- (void)loadRewardedAdForParameters:(id)parameters andNotify:(id)delegate +- (void)loadRewardedAdForParameters:(nonnull id)parameters andNotify:(nonnull id)delegate { - self.zoneId = parameters.thirdPartyAdPlacementIdentifier; - - [self log: @"Loading rewarded ad: %@...", self.zoneId]; - - [self.router addRewardedAdapter: self delegate: delegate forPlacementIdentifier: self.zoneId]; - - if ( [Maio canShowAtZoneId: self.zoneId] ) - { - [self.router didLoadAdForPlacementIdentifier: self.zoneId]; - } - // Maio might lose out on the first impression. - else - { - [self log: @"Ad failed to load for this zone: %@", self.zoneId]; - [self.router didFailToLoadAdForPlacementIdentifier: self.zoneId error: MAAdapterError.noFill]; - } + NSString *zoneID = parameters.thirdPartyAdPlacementIdentifier; + [self log: @"Loading rewarded ad: %@...", zoneID]; + + self.rewardedAdapterDelegate = [[ALMaioMediationAdapterRewardedAdDelegate alloc] initWithParentAdapter:self andNotify:delegate]; + + MaioRequest *request = [[MaioRequest alloc] initWithZoneId:zoneID testMode:self.isTesting]; + self.maioRewarded = [MaioRewarded loadAdWithRequest:request callback:self.rewardedAdapterDelegate]; } -- (void)showRewardedAdForParameters:(id)parameters andNotify:(id)delegate +- (void)showRewardedAdForParameters:(nonnull id)parameters andNotify:(nonnull id)delegate { - [self log: @"Showing rewarded ad %@", self.zoneId]; - - [self.router addShowingAdapter: self]; - - if ( [Maio canShowAtZoneId: self.zoneId] ) + [self log: @"Showing rewarded ad..."]; + + if ( self.maioRewarded != nil ) { - // Configure reward from server. - [self configureRewardForParameters: parameters]; - UIViewController *presentingViewController; if ( ALSdk.versionCode >= 11020199 ) { @@ -208,245 +139,236 @@ - (void)showRewardedAdForParameters:(id)parameters { presentingViewController = [ALUtils topViewControllerFromKeyWindow]; } - - [Maio showAtZoneId: self.zoneId vc: presentingViewController]; + + [self.maioRewarded showWithViewContext:presentingViewController callback:self.rewardedAdapterDelegate]; } else { [self log: @"Rewarded ad not ready"]; - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self.router didFailToDisplayAdForPlacementIdentifier: self.zoneId error: [MAAdapterError errorWithCode: -4205 - errorString: @"Ad Display Failed" - thirdPartySdkErrorCode: 0 - thirdPartySdkErrorMessage: @"Rewarded ad not ready"]]; -#pragma clang diagnostic pop + + [delegate didFailToDisplayRewardedAdWithError:[MAAdapterError errorWithCode:-4205 + errorString:@"Ad Display Failed" + mediatedNetworkErrorCode:0 + mediatedNetworkErrorMessage:@"Rewarded ad not ready"]]; } } -#pragma mark - Dynamic Properties +#pragma mark - Helper functions -- (ALMaioMediationAdapterRouter *)router +- (MAAdapterError *)toMaxError:(NSInteger)maioErrorCode { - return [ALMaioMediationAdapterRouter sharedInstance]; + NSString *errorCodeString = [NSString stringWithFormat:@"%ld", maioErrorCode]; + NSString *maioErrorMessage = @"Unknown"; + MAAdapterError *adapterError = MAAdapterError.unspecified; + + if ( [errorCodeString hasPrefix:@"101"] ) + { + maioErrorMessage = @"NoNetwork"; + adapterError = MAAdapterError.noConnection; + } + else if ( [errorCodeString hasPrefix:@"102"] ) + { + maioErrorMessage = @"NetworkTimeout"; + adapterError = MAAdapterError.timeout; + } + else if ( [errorCodeString hasPrefix:@"103"] ) + { + maioErrorMessage = @"AbortedDownload"; + adapterError = MAAdapterError.adNotReady; + } + else if ( [errorCodeString hasPrefix:@"104"] ) + { + maioErrorMessage = @"InvalidResponse"; + adapterError = MAAdapterError.serverError; + } + else if ( [errorCodeString hasPrefix:@"105"] ) + { + maioErrorMessage = @"ZoneNotFound"; + adapterError = MAAdapterError.invalidConfiguration; + } + else if ( [errorCodeString hasPrefix:@"106"] ) + { + maioErrorMessage = @"UnavailableZone"; + adapterError = MAAdapterError.invalidConfiguration; + } + else if ( [errorCodeString hasPrefix:@"107"] ) + { + maioErrorMessage = @"NoFill"; + adapterError = MAAdapterError.noFill; + } + else if ( [errorCodeString hasPrefix:@"108"] ) + { + maioErrorMessage = @"NilArgMaioRequest"; + adapterError = MAAdapterError.badRequest; + } + else if ( [errorCodeString hasPrefix:@"109"] ) + { + maioErrorMessage = @"DiskSpaceNotEnough"; + adapterError = MAAdapterError.internalError; + } + else if ( [errorCodeString hasPrefix:@"110"] ) + { + maioErrorMessage = @"UnsupportedOsVer"; + adapterError = MAAdapterError.unspecified; + } + else if ( [errorCodeString hasPrefix:@"201"] ) + { + maioErrorMessage = @"Expired"; + adapterError = MAAdapterError.adExpiredError; + } + else if ( [errorCodeString hasPrefix:@"202"] ) + { + maioErrorMessage = @"NotReadyYet"; + adapterError = MAAdapterError.adNotReady; + } + else if ( [errorCodeString hasPrefix:@"203"] ) + { + maioErrorMessage = @"AlreadyShown"; + adapterError = MAAdapterError.internalError; + } + else if ( [errorCodeString hasPrefix:@"204"] ) + { + maioErrorMessage = @"FailedPlayback"; + adapterError = MAAdapterError.webViewError; + } + else if ( [errorCodeString hasPrefix:@"205"] ) + { + maioErrorMessage = @"NilArgViewController"; + adapterError = MAAdapterError.missingViewController; + } + else + { + maioErrorMessage = @"Unknown"; + adapterError = MAAdapterError.unspecified; + } + + return [MAAdapterError errorWithCode:adapterError.code + errorString:adapterError.message + mediatedNetworkErrorCode:maioErrorCode + mediatedNetworkErrorMessage:maioErrorMessage]; } @end -@implementation ALMaioMediationAdapterRouter +#pragma mark - ALMaioMediationAdapterInterstitialAdDelegate -- (instancetype)init +@implementation ALMaioMediationAdapterInterstitialAdDelegate + +- (instancetype)initWithParentAdapter:(ALMaioMediationAdapter *)parentAdapter andNotify:(id)delegate { self = [super init]; if ( self ) { - self.isShowingAd = [[ALAtomicBoolean alloc] init]; + self.parentAdapter = parentAdapter; + self.delegate = delegate; } return self; } -#pragma mark - Override for Ad Show - -- (void)addShowingAdapter:(id)showingAdapter +- (void)didLoad:(MaioInterstitial *)ad { - [super addShowingAdapter: showingAdapter]; - - // Maio uses the same callback for [AD LOADĀ FAILED] and [AD DISPLAY FAILED] callbacks - [self.isShowingAd set: YES]; + [self.parentAdapter log: @"Interstitial ad loaded: %@", ad.request.zoneId]; + [self.delegate didLoadInterstitialAd]; } -#pragma mark - Maio Delegate Methods +- (void)didOpen:(MaioInterstitial *)ad +{ + [self.parentAdapter log: @"Interstitial ad started: %@", ad.request.zoneId]; + [self.delegate didDisplayInterstitialAd]; +} -- (void)maioDidInitialize +- (void)didClose:(MaioInterstitial *)ad { - [self log: @"Maio SDK initialized"]; - - if ( self.oldCompletionHandler ) - { - self.oldCompletionHandler(); - self.oldCompletionHandler = nil; - } - - if ( self.newCompletionHandler ) - { - ALMaioIntializationStatus = MAAdapterInitializationStatusInitializedUnknown; - - self.newCompletionHandler(ALMaioIntializationStatus, nil); - self.newCompletionHandler = nil; - } + [self.parentAdapter log: @"Interstitial ad closed: %@", ad.request.zoneId]; + [self.delegate didHideInterstitialAd]; } -// Does not refer to a specific ad, but if ads can show in general. -- (void)maioDidChangeCanShow:(NSString *)zoneId newValue:(BOOL)newValue +- (void)didFail:(MaioInterstitial *)ad errorCode:(NSInteger)errorCode { - if ( newValue ) + MAAdapterError *error = [self.parentAdapter toMaxError:errorCode]; + + if ( 10000 <= errorCode && errorCode < 20000 ) + { + // Fail to load. + [self.parentAdapter log: @"Interstitial ad failed to load with Maio reason: %@, and MAX error: %@", error.mediatedNetworkErrorMessage, error]; + [self.delegate didFailToLoadInterstitialAdWithError:error]; + } + else if ( 20000 <= errorCode && errorCode < 30000 ) { - [self log: @"Maio can show ads: %@", zoneId]; + // Fail to show. + [self.parentAdapter log: @"Interstitial ad failed to display with Maio reason: %@ and MAX error: %@", error.mediatedNetworkErrorMessage, error]; + [self.delegate didFailToDisplayInterstitialAdWithError:error]; } else { - [self log: @"Maio cannot show ads: %@", zoneId]; + // Unknown error code + [self.delegate didFailToLoadInterstitialAdWithError:error]; } } -- (void)maioWillStartAd:(NSString *)zoneId -{ - [self log: @"Ad video started: %@", zoneId]; - [self didDisplayAdForPlacementIdentifier: zoneId]; - [self didStartRewardedVideoForPlacementIdentifier: zoneId]; -} +@end -- (void)maioDidClickAd:(NSString *)zoneId -{ - [self log: @"Ad clicked: %@", zoneId]; - [self didClickAdForPlacementIdentifier: zoneId]; -} +#pragma mark - ALMaioMediationAdapterRewardedAdDelegate -- (void)maioDidFinishAd:(NSString *)zoneId playtime:(NSInteger)playtime skipped:(BOOL)skipped rewardParam:(NSString *)rewardParam +@implementation ALMaioMediationAdapterRewardedAdDelegate + +- (instancetype)initWithParentAdapter:(ALMaioMediationAdapter *)parentAdapter andNotify:(id)delegate { - [self log: @"Did finish ad=%@, playtime=%ld, skipped=%d, rewardParam=%@", zoneId, playtime, skipped, rewardParam]; - - if ( !skipped ) + self = [super init]; + if ( self ) { - self.grantedReward = YES; + self.parentAdapter = parentAdapter; + self.delegate = delegate; } - - [self didCompleteRewardedVideoForPlacementIdentifier: zoneId]; + return self; } -- (void)maioDidCloseAd:(NSString *)zoneId +- (void)didLoad:(MaioRewarded *)ad { - [self log: @"Ad closed: %@", zoneId]; - - if ( [self hasGrantedReward] || [self shouldAlwaysRewardUserForPlacementIdentifier: zoneId] ) - { - MAReward *reward = [self rewardForPlacementIdentifier: zoneId]; - [self log: @"Rewarded ad user with reward: %@", reward]; - [self didRewardUserForPlacementIdentifier: zoneId withReward: reward]; - - self.grantedReward = NO; - } - - [self.isShowingAd set: NO]; - - [self didHideAdForPlacementIdentifier: zoneId]; + [self.parentAdapter log: @"Rewarded ad loaded: %@", ad.request.zoneId]; + [self.delegate didLoadRewardedAd]; } -- (void)maioDidFail:(NSString *)zoneId reason:(MaioFailReason)reason +- (void)didOpen:(MaioRewarded *)ad { - MAAdapterError *error = [ALMaioMediationAdapterRouter toMaxError: reason]; - - if ( [self.isShowingAd compareAndSet: YES update: NO] ) - { - [self log: @"Ad failed to display with Maio reason: %@ and MAX error: %@", [self reasonToString: reason], error]; - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self didFailToDisplayAdForPlacementIdentifier: zoneId error: [MAAdapterError errorWithCode: -4205 - errorString: @"Ad Display Failed" - thirdPartySdkErrorCode: reason - thirdPartySdkErrorMessage: [self reasonToString: reason]]]; -#pragma clang diagnostic pop - } - else - { - [self log: @"Ad failed to load with Maio reason: %@, and MAX error: %@", [self reasonToString: reason], error]; - [self didFailToLoadAdForPlacementIdentifier: zoneId error: error]; - } + [self.parentAdapter log: @"Rewarded ad started: %@", ad.request.zoneId]; + [self.delegate didDisplayRewardedAd]; } -#pragma mark - Helper functions +- (void)didClose:(MaioRewarded *)ad +{ + [self.parentAdapter log: @"Rewarded ad closed: %@", ad.request.zoneId]; + [self.delegate didHideRewardedAd]; +} -+ (MAAdapterError *)toMaxError:(MaioFailReason)maioErrorCode +- (void)didReward:(MaioRewarded *)ad reward:(RewardData *)reward { - MAAdapterError *adapterError = MAAdapterError.unspecified; - switch ( maioErrorCode ) - { - case MaioFailReasonAdStockOut: - adapterError = MAAdapterError.noFill; - break; - case MaioFailReasonNetworkConnection: - adapterError = MAAdapterError.noConnection; - break; - case MaioFailReasonNetworkClient: - adapterError = MAAdapterError.badRequest; - break; - case MaioFailReasonNetworkServer: - case MaioFailReasonSdk: - adapterError = MAAdapterError.serverError; - break; - case MaioFailReasonDownloadCancelled: - adapterError = MAAdapterError.adNotReady; - break; - case MaioFailReasonVideoPlayback: - adapterError = MAAdapterError.internalError; - break; - case MaioFailReasonIncorrectMediaId: - case MaioFailReasonIncorrectZoneId: - adapterError = MAAdapterError.invalidConfiguration; - break; - case MaioFailReasonNotFoundViewContext: - case MaioFailReasonUnknown: - adapterError = MAAdapterError.unspecified; - break; - } - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - return [MAAdapterError errorWithCode: adapterError.errorCode - errorString: adapterError.errorMessage - thirdPartySdkErrorCode: maioErrorCode - thirdPartySdkErrorMessage: @""]; -#pragma clang diagnostic pop + MAReward *maReward = [self.parentAdapter reward]; + [self.parentAdapter log: @"Rewarded user with reward: %@", maReward]; + [self.delegate didRewardUserWithReward:maReward]; } -- (NSString *)reasonToString:(MaioFailReason)reason +- (void)didFail:(MaioRewarded *)ad errorCode:(NSInteger)errorCode { - NSString *errorString; - - if ( reason == MaioFailReasonAdStockOut ) - { - errorString = @"Ad Stock Out"; - } - else if ( reason == MaioFailReasonNetworkConnection ) - { - errorString = @"Network Connection"; - } - else if ( reason == MaioFailReasonNetworkClient ) - { - errorString = @"Client Network"; - } - else if ( reason == MaioFailReasonNetworkServer ) - { - errorString = @"Server Network"; - } - else if ( reason == MaioFailReasonSdk ) - { - errorString = @"Maio SDK Issue"; - } - else if ( reason == MaioFailReasonDownloadCancelled ) - { - errorString = @"Download Cancelled"; - } - else if ( reason == MaioFailReasonVideoPlayback ) - { - errorString = @"Video Playback Issue"; - } - else if ( reason == MaioFailReasonIncorrectMediaId ) + MAAdapterError *error = [self.parentAdapter toMaxError:errorCode]; + + if ( 10000 <= errorCode && errorCode < 20000 ) { - errorString = @"Incorrect media id"; + // Fail to load. + [self.parentAdapter log: @"Rewarded ad failed to load with Maio reason: %@, and MAX error: %@", error.mediatedNetworkErrorMessage, error]; + [self.delegate didFailToLoadRewardedAdWithError:error]; } - else if ( reason == MaioFailReasonIncorrectZoneId ) + else if ( 20000 <= errorCode && errorCode < 30000 ) { - errorString = @"Incorrect zone id"; + // Fail to show. + [self.parentAdapter log: @"Rewarded ad failed to display with Maio reason: %@ and MAX error: %@", error.mediatedNetworkErrorMessage, error]; + [self.delegate didFailToDisplayRewardedAdWithError:error]; } else { - errorString = @"Unknown Issue"; + // Unknown error code + [self.delegate didFailToLoadRewardedAdWithError:error]; } - - return errorString; } @end From 6f055e90991e154c20e0ec0692cc3a3398b9829d Mon Sep 17 00:00:00 2001 From: sfukui66 Date: Thu, 12 Oct 2023 12:07:47 +0900 Subject: [PATCH 2/2] Update MaioAdapter version: 2.1.1.0 Support click callback. --- Maio/AppLovinMediationMaioAdapter.podspec | 4 ++-- Maio/MaioAdapter/ALMaioMediationAdapter.m | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Maio/AppLovinMediationMaioAdapter.podspec b/Maio/AppLovinMediationMaioAdapter.podspec index c8206b1cec..e4fe9d0ed3 100644 --- a/Maio/AppLovinMediationMaioAdapter.podspec +++ b/Maio/AppLovinMediationMaioAdapter.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.authors = 'AppLovin Corporation' s.name = 'AppLovinMediationMaioAdapter' -s.version = '2.0.0.0' +s.version = '2.1.1.0' s.platform = :ios, '9.0' s.summary = 'Maio adapter used for mediation with the AppLovin MAX SDK' s.homepage = "https://github.com/CocoaPods/Specs/search?o=desc&q=#{s.name}&s=indexed" @@ -26,7 +26,7 @@ s.source = s.vendored_frameworks = "#{s.name}-#{s.version}/#{s.name}.xcframework" -s.dependency 'MaioSDK-v2', '= 2.0.0' +s.dependency 'MaioSDK-v2', '= 2.1.1' s.dependency 'AppLovinSDK' s.description = <<-DESC diff --git a/Maio/MaioAdapter/ALMaioMediationAdapter.m b/Maio/MaioAdapter/ALMaioMediationAdapter.m index 23bee23235..87b9506300 100644 --- a/Maio/MaioAdapter/ALMaioMediationAdapter.m +++ b/Maio/MaioAdapter/ALMaioMediationAdapter.m @@ -9,7 +9,7 @@ #import "ALMaioMediationAdapter.h" #import -#define ADAPTER_VERSION @"2.0.0.0" +#define ADAPTER_VERSION @"2.1.1.0" @interface ALMaioMediationAdapterInterstitialAdDelegate : NSObject @property (nonatomic, weak) ALMaioMediationAdapter *parentAdapter; @@ -283,6 +283,12 @@ - (void)didClose:(MaioInterstitial *)ad [self.delegate didHideInterstitialAd]; } +- (void)didClick:(MaioInterstitial *)ad +{ + [self.parentAdapter log: @"Interstitial ad clicked: %@", ad.request.zoneId]; + [self.delegate didClickInterstitialAd]; +} + - (void)didFail:(MaioInterstitial *)ad errorCode:(NSInteger)errorCode { MAAdapterError *error = [self.parentAdapter toMaxError:errorCode]; @@ -348,6 +354,12 @@ - (void)didReward:(MaioRewarded *)ad reward:(RewardData *)reward [self.delegate didRewardUserWithReward:maReward]; } +- (void)didClick:(MaioRewarded *)ad +{ + [self.parentAdapter log: @"Rewarded ad clicked: %@", ad.request.zoneId]; + [self.delegate didClickRewardedAd]; +} + - (void)didFail:(MaioRewarded *)ad errorCode:(NSInteger)errorCode { MAAdapterError *error = [self.parentAdapter toMaxError:errorCode];