This commit is contained in:
jenkins 2023-09-25 14:17:57 -07:00
Родитель 0f8976982f
Коммит 63d3a5fde2
3 изменённых файлов: 60 добавлений и 93 удалений

Просмотреть файл

@ -2,8 +2,8 @@ Pod::Spec.new do |s|
s.authors = 'AppLovin Corporation' s.authors = 'AppLovin Corporation'
s.name = 'AppLovinMediationYandexAdapter' s.name = 'AppLovinMediationYandexAdapter'
s.version = '5.9.1.0' s.version = '6.0.0.0'
s.platform = :ios, '12.0' s.platform = :ios, '13.0'
s.summary = 'Yandex adapter used for mediation with the AppLovin MAX SDK' s.summary = 'Yandex adapter used for mediation with the AppLovin MAX SDK'
s.homepage = "https://github.com/CocoaPods/Specs/search?o=desc&q=#{s.name}&s=indexed" s.homepage = "https://github.com/CocoaPods/Specs/search?o=desc&q=#{s.name}&s=indexed"
s.license = s.license =
@ -26,7 +26,7 @@ s.source =
s.vendored_frameworks = "#{s.name}-#{s.version}/#{s.name}.xcframework" s.vendored_frameworks = "#{s.name}-#{s.version}/#{s.name}.xcframework"
s.dependency 'YandexMobileAds', '= 5.9.1' s.dependency 'YandexMobileAds', '= 6.0.0'
s.dependency 'AppLovinSDK' s.dependency 'AppLovinSDK'
s.swift_version = '5.7' s.swift_version = '5.7'

Просмотреть файл

@ -1,5 +1,9 @@
# Changelog # Changelog
## 6.0.0.0
* Certified with Yandex SDK 6.0.0.
* Updated the minimum required iOS version to 13.0 to match Yandex SDK.
## 5.9.1.0 ## 5.9.1.0
* Certified with Yandex SDK 5.9.1. * Certified with Yandex SDK 5.9.1.

Просмотреть файл

@ -9,12 +9,12 @@
#import "ALYandexMediationAdapter.h" #import "ALYandexMediationAdapter.h"
#import <YandexMobileAds/YandexMobileAds.h> #import <YandexMobileAds/YandexMobileAds.h>
#define ADAPTER_VERSION @"5.9.1.0" #define ADAPTER_VERSION @"6.0.0.0"
/** /**
* Dedicated delegate object for Yandex interstitial ads. * Dedicated delegate object for Yandex interstitial ads.
*/ */
@interface ALYandexMediationAdapterInterstitialAdDelegate : NSObject <YMAInterstitialAdDelegate> @interface ALYandexMediationAdapterInterstitialAdDelegate : NSObject <YMAInterstitialAdLoaderDelegate, YMAInterstitialAdDelegate>
@property (nonatomic, weak) ALYandexMediationAdapter *parentAdapter; @property (nonatomic, weak) ALYandexMediationAdapter *parentAdapter;
@property (nonatomic, strong) id<MAAdapterResponseParameters> parameters; @property (nonatomic, strong) id<MAAdapterResponseParameters> parameters;
@ -27,7 +27,7 @@
/** /**
* Dedicated delegate object for Yandex rewarded ads. * Dedicated delegate object for Yandex rewarded ads.
*/ */
@interface ALYandexMediationAdapterRewardedAdDelegate : NSObject <YMARewardedAdDelegate> @interface ALYandexMediationAdapterRewardedAdDelegate : NSObject <YMARewardedAdLoaderDelegate, YMARewardedAdDelegate>
@property (nonatomic, weak) ALYandexMediationAdapter *parentAdapter; @property (nonatomic, weak) ALYandexMediationAdapter *parentAdapter;
@property (nonatomic, strong) id<MAAdapterResponseParameters> parameters; @property (nonatomic, strong) id<MAAdapterResponseParameters> parameters;
@ -58,10 +58,12 @@
// Interstitial // Interstitial
@property (nonatomic, strong) YMAInterstitialAd *interstitialAd; @property (nonatomic, strong) YMAInterstitialAd *interstitialAd;
@property (nonatomic, strong) ALYandexMediationAdapterInterstitialAdDelegate *interstitialAdapterDelegate; @property (nonatomic, strong) ALYandexMediationAdapterInterstitialAdDelegate *interstitialAdapterDelegate;
@property (nonatomic, strong) YMAInterstitialAdLoader *interstitialAdLoader;
// Rewarded // Rewarded
@property (nonatomic, strong) YMARewardedAd *rewardedAd; @property (nonatomic, strong) YMARewardedAd *rewardedAd;
@property (nonatomic, strong) ALYandexMediationAdapterRewardedAdDelegate *rewardedAdapterDelegate; @property (nonatomic, strong) ALYandexMediationAdapterRewardedAdDelegate *rewardedAdapterDelegate;
@property (nonatomic, strong) YMARewardedAdLoader *rewardedAdLoader;
// AdView // AdView
@property (nonatomic, strong) YMAAdView *adView; @property (nonatomic, strong) YMAAdView *adView;
@ -112,11 +114,15 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
self.interstitialAd = nil; self.interstitialAd = nil;
self.interstitialAdapterDelegate.delegate = nil; self.interstitialAdapterDelegate.delegate = nil;
self.interstitialAdapterDelegate = nil; self.interstitialAdapterDelegate = nil;
self.interstitialAdLoader.delegate = nil;
self.interstitialAdLoader = nil;
self.rewardedAd.delegate = nil; self.rewardedAd.delegate = nil;
self.rewardedAd = nil; self.rewardedAd = nil;
self.rewardedAdapterDelegate.delegate = nil; self.rewardedAdapterDelegate.delegate = nil;
self.rewardedAdapterDelegate = nil; self.rewardedAdapterDelegate = nil;
self.rewardedAdLoader.delegate = nil;
self.rewardedAdLoader = nil;
self.adView.delegate = nil; self.adView.delegate = nil;
self.adView = nil; self.adView = nil;
@ -145,28 +151,21 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
[self updateUserConsent: parameters]; [self updateUserConsent: parameters];
self.interstitialAd = [[YMAInterstitialAd alloc] initWithAdUnitID: placementId]; self.interstitialAdLoader = [[YMAInterstitialAdLoader alloc] init];
self.interstitialAdapterDelegate = [[ALYandexMediationAdapterInterstitialAdDelegate alloc] initWithParentAdapter: self self.interstitialAdapterDelegate = [[ALYandexMediationAdapterInterstitialAdDelegate alloc] initWithParentAdapter: self
withParameters: parameters withParameters: parameters
andNotify: delegate]; andNotify: delegate];
self.interstitialAd.delegate = self.interstitialAdapterDelegate; self.interstitialAdLoader.delegate = self.interstitialAdapterDelegate;
// This feature doesn't work yet when set to YES YMAMutableAdRequestConfiguration *configuration = [self createAdRequestConfigurationForPlacementId: placementId parameters: parameters];
// Default is NO [self.interstitialAdLoader loadAdWithRequestConfiguration: configuration];
NSDictionary<NSString *, id> *serverParameters = [parameters serverParameters];
if ( [serverParameters al_containsValueForKey: @"should_open_links_in_app"] )
{
self.interstitialAd.shouldOpenLinksInApp = [serverParameters al_numberForKey: @"should_open_links_in_app"].boolValue;
}
[self.interstitialAd loadWithRequest: [self createAdRequestWithParameters: parameters]];
} }
- (void)showInterstitialAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MAInterstitialAdapterDelegate>)delegate - (void)showInterstitialAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MAInterstitialAdapterDelegate>)delegate
{ {
[self log: @"Showing interstitial ad..."]; [self log: @"Showing interstitial ad..."];
if ( !self.interstitialAd || ![self.interstitialAd loaded] ) if ( !self.interstitialAd )
{ {
[self log: @"Interstitial ad failed to show - ad not ready"]; [self log: @"Interstitial ad failed to show - ad not ready"];
@ -191,7 +190,7 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
presentingViewController = [ALUtils topViewControllerFromKeyWindow]; presentingViewController = [ALUtils topViewControllerFromKeyWindow];
} }
[self.interstitialAd presentFromViewController: presentingViewController]; [self.interstitialAd showFromViewController: presentingViewController];
} }
#pragma mark - MARewardedAdapter Methods #pragma mark - MARewardedAdapter Methods
@ -203,28 +202,21 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
[self updateUserConsent: parameters]; [self updateUserConsent: parameters];
self.rewardedAd = [[YMARewardedAd alloc] initWithAdUnitID: placementId]; self.rewardedAdLoader = [[YMARewardedAdLoader alloc] init];
self.rewardedAdapterDelegate = [[ALYandexMediationAdapterRewardedAdDelegate alloc] initWithParentAdapter: self self.rewardedAdapterDelegate = [[ALYandexMediationAdapterRewardedAdDelegate alloc] initWithParentAdapter: self
withParameters: parameters withParameters: parameters
andNotify: delegate]; andNotify: delegate];
self.rewardedAd.delegate = self.rewardedAdapterDelegate; self.rewardedAdLoader.delegate = self.rewardedAdapterDelegate;
// This feature doesn't work yet when set to YES YMAMutableAdRequestConfiguration *configuration = [self createAdRequestConfigurationForPlacementId: placementId parameters: parameters];
// Default is NO [self.rewardedAdLoader loadAdWithRequestConfiguration: configuration];
NSDictionary<NSString *, id> *serverParameters = [parameters serverParameters];
if ( [serverParameters al_containsValueForKey: @"should_open_links_in_app"] )
{
self.rewardedAd.shouldOpenLinksInApp = [serverParameters al_numberForKey: @"should_open_links_in_app"].boolValue;
}
[self.rewardedAd loadWithRequest: [self createAdRequestWithParameters: parameters]];
} }
- (void)showRewardedAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MARewardedAdapterDelegate>)delegate - (void)showRewardedAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MARewardedAdapterDelegate>)delegate
{ {
[self log: @"Showing rewarded ad..."]; [self log: @"Showing rewarded ad..."];
if ( !self.rewardedAd || ![self.rewardedAd loaded] ) if ( !self.rewardedAd )
{ {
[self log: @"Rewarded ad failed to show - ad not ready"]; [self log: @"Rewarded ad failed to show - ad not ready"];
@ -252,7 +244,7 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
presentingViewController = [ALUtils topViewControllerFromKeyWindow]; presentingViewController = [ALUtils topViewControllerFromKeyWindow];
} }
[self.rewardedAd presentFromViewController: presentingViewController]; [self.rewardedAd showFromViewController: presentingViewController];
} }
#pragma mark - MAAdViewAdapter Methods #pragma mark - MAAdViewAdapter Methods
@ -298,9 +290,23 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
return adRequest; return adRequest;
} }
- (YMAAdSize *)adSizeFromAdFormat:(MAAdFormat *)adFormat - (YMAMutableAdRequestConfiguration *)createAdRequestConfigurationForPlacementId:(NSString *)placementId parameters:(id<MAAdapterResponseParameters>)parameters
{ {
return [YMAAdSize flexibleSizeWithCGSize: adFormat.size]; NSDictionary *adRequestParameters = @{@"adapter_network_name" : @"applovin",
@"adapter_version" : ADAPTER_VERSION,
@"adapter_network_sdk_version" : ALSdk.version};
YMAMutableAdRequestConfiguration *configuration = [[YMAMutableAdRequestConfiguration alloc] initWithAdUnitID: placementId];
configuration.parameters = adRequestParameters;
configuration.biddingData = parameters.bidResponse;
return configuration;
}
- (YMABannerAdSize *)adSizeFromAdFormat:(MAAdFormat *)adFormat
{
return [YMABannerAdSize fixedSizeWithWidth: adFormat.size.width height: adFormat.size.height];
} }
+ (MAAdapterError *)toMaxError:(NSError *)yandexError + (MAAdapterError *)toMaxError:(NSError *)yandexError
@ -314,6 +320,7 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
case YMAAdErrorCodeNoSuchAdUnitID: case YMAAdErrorCodeNoSuchAdUnitID:
case YMAAdErrorCodeAdTypeMismatch: case YMAAdErrorCodeAdTypeMismatch:
case YMAAdErrorCodeAdSizeMismatch: case YMAAdErrorCodeAdSizeMismatch:
case YMAAdErrorCodeInvalidSDKConfiguration:
adapterError = MAAdapterError.invalidConfiguration; adapterError = MAAdapterError.invalidConfiguration;
break; break;
case YMAAdErrorCodeNoFill: case YMAAdErrorCodeNoFill:
@ -361,26 +368,23 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
return self; return self;
} }
- (void)interstitialAdDidLoad:(YMAInterstitialAd *)interstitial - (void)interstitialAdLoader:(YMAInterstitialAdLoader *)adLoader didLoad:(YMAInterstitialAd *)interstitialAd
{ {
[self.parentAdapter log: @"Interstitial ad loaded"]; [self.parentAdapter log: @"Interstitial ad loaded"];
self.parentAdapter.interstitialAd = interstitialAd;
[self.delegate didLoadInterstitialAd]; [self.delegate didLoadInterstitialAd];
} }
- (void)interstitialAdDidFailToLoad:(YMAInterstitialAd *)interstitial error:(NSError *)error - (void)interstitialAdLoader:(YMAInterstitialAdLoader *)adLoader didFailToLoadWithError:(YMAAdRequestError *)yandexError
{ {
NSError *error = yandexError.error;
[self.parentAdapter log: @"Interstitial ad failed to load with error code %ld and description: %@", error.code, error.description]; [self.parentAdapter log: @"Interstitial ad failed to load with error code %ld and description: %@", error.code, error.description];
MAAdapterError *adapterError = [ALYandexMediationAdapter toMaxError: error]; MAAdapterError *adapterError = [ALYandexMediationAdapter toMaxError: error];
[self.delegate didFailToLoadInterstitialAdWithError: adapterError]; [self.delegate didFailToLoadInterstitialAdWithError: adapterError];
} }
- (void)interstitialAdWillAppear:(YMAInterstitialAd *)interstitial - (void)interstitialAdDidShow:(YMAInterstitialAd *)interstitialAd
{
[self.parentAdapter log: @"Interstitial ad will show"];
}
- (void)interstitialAdDidAppear:(YMAInterstitialAd *)interstitial
{ {
[self.parentAdapter log: @"Interstitial ad shown"]; [self.parentAdapter log: @"Interstitial ad shown"];
@ -399,7 +403,7 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
[self.delegate didDisplayInterstitialAd]; [self.delegate didDisplayInterstitialAd];
} }
- (void)interstitialAdDidFailToPresent:(YMAInterstitialAd *)interstitial error:(NSError *)error - (void)interstitialAd:(YMAInterstitialAd *)interstitialAd didFailToShowWithError:(NSError *)error
{ {
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" #pragma clang diagnostic ignored "-Wdeprecated-declarations"
@ -419,26 +423,7 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
[self.delegate didClickInterstitialAd]; [self.delegate didClickInterstitialAd];
} }
- (void)interstitialAd:(YMAInterstitialAd *)interstitialAd willPresentScreen:(nullable UIViewController *)webBrowser - (void)interstitialAdDidDismiss:(YMAInterstitialAd *)interstitialAd
{
// This callback and interstitialWillLeaveApplication are mutually exclusive
// Ad either opens in-app or redirects to another app
[self.parentAdapter log: @"Interstitial ad clicked and in-app browser opened"];
}
- (void)interstitialAdWillLeaveApplication:(YMAInterstitialAd *)interstitial
{
// This callback and interstitialWillPresentScreen are mutually exclusive
// Ad either opens in-app or redirects to another app
[self.parentAdapter log: @"Interstitial ad clicked and left application"];
}
- (void)interstitialAdWillDisappear:(YMAInterstitialAd *)interstitial
{
[self.parentAdapter log: @"Interstitial ad will be hidden"];
}
- (void)interstitialAdDidDisappear:(YMAInterstitialAd *)interstitial
{ {
[self.parentAdapter log: @"Interstitial ad hidden"]; [self.parentAdapter log: @"Interstitial ad hidden"];
[self.delegate didHideInterstitialAd]; [self.delegate didHideInterstitialAd];
@ -462,26 +447,23 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
return self; return self;
} }
- (void)rewardedAdDidLoad:(YMARewardedAd *)rewardedAd - (void)rewardedAdLoader:(YMARewardedAdLoader *)adLoader didLoad:(YMARewardedAd *)rewardedAd
{ {
[self.parentAdapter log: @"Rewarded ad loaded"]; [self.parentAdapter log: @"Rewarded ad loaded"];
self.parentAdapter.rewardedAd = rewardedAd;
[self.delegate didLoadRewardedAd]; [self.delegate didLoadRewardedAd];
} }
- (void)rewardedAdDidFailToLoad:(YMARewardedAd *)rewardedAd error:(NSError *)error - (void)rewardedAdLoader:(YMARewardedAdLoader *)adLoader didFailToLoadWithError:(YMAAdRequestError *)yandexError
{ {
[self.parentAdapter log: @"Rewarded ad failed to display with error code %ld and description: %@", error.code, error.description]; NSError *error = yandexError.error;
[self.parentAdapter log: @"Rewarded ad failed to load with error code %ld and description: %@", error.code, error.description];
MAAdapterError *adapterError = [ALYandexMediationAdapter toMaxError: error]; MAAdapterError *adapterError = [ALYandexMediationAdapter toMaxError: error];
[self.delegate didFailToLoadRewardedAdWithError: adapterError]; [self.delegate didFailToLoadRewardedAdWithError: adapterError];
} }
- (void)rewardedAdWillAppear:(YMARewardedAd *)rewardedAd - (void)rewardedAdDidShow:(YMARewardedAd *)rewardedAd
{
[self.parentAdapter log: @"Rewarded ad will show"];
}
- (void)rewardedAdDidAppear:(YMARewardedAd *)rewardedAd
{ {
[self.parentAdapter log: @"Rewarded ad shown"]; [self.parentAdapter log: @"Rewarded ad shown"];
@ -502,7 +484,7 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
[self.delegate didStartRewardedAdVideo]; [self.delegate didStartRewardedAdVideo];
} }
- (void)rewardedAdDidFailToPresent:(YMARewardedAd *)rewardedAd error:(NSError *)error - (void)rewardedAd:(YMARewardedAd *)rewardedAd didFailToShowWithError:(NSError *)error
{ {
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" #pragma clang diagnostic ignored "-Wdeprecated-declarations"
@ -522,32 +504,13 @@ static YMABidderTokenLoader *ALYandexBidderTokenLoader;
[self.delegate didClickRewardedAd]; [self.delegate didClickRewardedAd];
} }
- (void)rewardedAd:(YMARewardedAd *)rewardedAd willPresentScreen:(UIViewController *)viewController
{
// This callback and rewardedAdWillLeaveApplication are mutually exclusive
// Ad either opens in-app or redirects to another app
[self.parentAdapter log: @"Rewarded ad clicked and in-app browser opened"];
}
- (void)rewardedAdWillLeaveApplication:(YMARewardedAd *)rewardedAd
{
// This callback and willPresentScreen are mutually exclusive
// Ad either opens in-app or redirects to another app
[self.parentAdapter log: @"Rewarded ad clicked and left application"];
}
- (void)rewardedAd:(YMARewardedAd *)rewardedAd didReward:(id<YMAReward>)reward - (void)rewardedAd:(YMARewardedAd *)rewardedAd didReward:(id<YMAReward>)reward
{ {
[self.parentAdapter log: @"Rewarded ad user with reward: %@", reward]; [self.parentAdapter log: @"Rewarded ad user with reward: %@", reward];
self.grantedReward = YES; self.grantedReward = YES;
} }
- (void)rewardedAdWillDisappear:(YMARewardedAd *)rewardedAd - (void)rewardedAdDidDismiss:(YMARewardedAd *)rewardedAd
{
[self.parentAdapter log: @"Rewarded ad will be hidden"];
}
- (void)rewardedAdDidDisappear:(YMARewardedAd *)rewardedAd
{ {
[self.parentAdapter log: @"Rewarded ad hidden"]; [self.parentAdapter log: @"Rewarded ad hidden"];
[self.delegate didCompleteRewardedAdVideo]; [self.delegate didCompleteRewardedAdVideo];