Skip to content

Commit

Permalink
Google/9.11.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins committed Sep 24, 2022
1 parent fe29625 commit 3808e87
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Google/AppLovinMediationGoogleAdapter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ s.authors =
'AppLovin Corporation' => '[email protected]'
}
s.name = 'AppLovinMediationGoogleAdapter'
s.version = '9.11.0.0'
s.version = '9.11.0.1'
s.platform = :ios, '10.0'
s.summary = 'Google adapter used for mediation with the AppLovin MAX SDK'
s.homepage = "https://github.com/CocoaPods/Specs/search?o=desc&q=#{s.name}&s=indexed"
Expand Down
3 changes: 3 additions & 0 deletions Google/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 9.11.0.1
* App open updates.

## 9.11.0.0
* Certified with Google SDK 9.11.0.

Expand Down
2 changes: 1 addition & 1 deletion Google/GoogleAdapter/ALGoogleMediationAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef void (^GADQueryInfoCreationCompletionHandler)(GADQueryInfo *_Nullable qu

@end

@interface ALGoogleMediationAdapter : ALMediationAdapter<MASignalProvider, MAInterstitialAdapter, /* MAAppOpenAdapter */ MARewardedInterstitialAdapter, MARewardedAdapter, MAAdViewAdapter, MANativeAdAdapter>
@interface ALGoogleMediationAdapter : ALMediationAdapter<MASignalProvider, MAInterstitialAdapter, MAAppOpenAdapter, MARewardedInterstitialAdapter, MARewardedAdapter, MAAdViewAdapter, MANativeAdAdapter>

/**
* Maps the provided ad network's error to an instance of @c MAAdapterError.
Expand Down
154 changes: 109 additions & 45 deletions Google/GoogleAdapter/ALGoogleMediationAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
#import "ALGoogleNativeAdViewDelegate.h"
#import "ALGoogleNativeAdDelegate.h"

#define ADAPTER_VERSION @"9.11.0.0"
#define ADAPTER_VERSION @"9.11.0.1"

@interface ALGoogleMediationAdapter()

@property (nonatomic, strong) GADInterstitialAd *interstitialAd;
@property (nonatomic, strong) GADAppOpenAd *appOpenAd;
@property (nonatomic, strong) GADInterstitialAd *appOpenInterstitialAd;
@property (nonatomic, strong) GADRewardedInterstitialAd *rewardedInterstitialAd;
@property (nonatomic, strong) GADRewardedAd *rewardedAd;
@property (nonatomic, strong) GADBannerView *adView;
Expand All @@ -31,6 +32,7 @@ @interface ALGoogleMediationAdapter()

@property (nonatomic, strong) ALGoogleInterstitialDelegate *interstitialDelegate;
@property (nonatomic, strong) ALGoogleAppOpenDelegate *appOpenDelegate;
@property (nonatomic, strong) ALGoogleAppOpenDelegate *appOpenInterstitialAdDelegate;
@property (nonatomic, strong) ALGoogleRewardedInterstitialDelegate *rewardedInterstitialDelegate;
@property (nonatomic, strong) ALGoogleRewardedDelegate *rewardedDelegate;
@property (nonatomic, strong) ALGoogleAdViewDelegate *adViewDelegate;
Expand Down Expand Up @@ -112,6 +114,10 @@ - (void)destroy
self.appOpenAd = nil;
self.appOpenDelegate = nil;

self.appOpenInterstitialAd.fullScreenContentDelegate = nil;
self.appOpenInterstitialAd = nil;
self.appOpenInterstitialAdDelegate = nil;

self.rewardedInterstitialAd.fullScreenContentDelegate = nil;
self.rewardedInterstitialAd = nil;
self.rewardedInterstitialDelegate = nil;
Expand Down Expand Up @@ -249,63 +255,121 @@ - (void)loadAppOpenAdForParameters:(id<MAAdapterResponseParameters>)parameters a
{
NSString *placementIdentifier = parameters.thirdPartyAdPlacementIdentifier;
BOOL isBiddingAd = [parameters.bidResponse al_isValidString];
[self log: @"Loading %@app open ad: %@...", ( isBiddingAd ? @"bidding " : @"" ), placementIdentifier];

BOOL isInterstitial = [parameters.serverParameters al_boolForKey: @"is_inter_placement"];

[self log: @"Loading %@app open %@ad: %@...", ( isBiddingAd ? @"bidding " : @"" ), ( isInterstitial ? @"interstitial " : @"" ), placementIdentifier];

[self updateMuteStateFromResponseParameters: parameters];
[self setRequestConfigurationWithParameters: parameters];
GADRequest *request = [self createAdRequestForBiddingAd: isBiddingAd
adFormat: nil // MAAdFormat.appOpen
withParameters: parameters];
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;

[GADAppOpenAd loadWithAdUnitID: placementIdentifier
request: request
orientation: orientation
completionHandler:^(GADAppOpenAd *_Nullable appOpenAd, NSError *_Nullable error) {
if ( isInterstitial )
{
GADRequest *request = [self createAdRequestForBiddingAd: isBiddingAd
adFormat: MAAdFormat.interstitial
withParameters: parameters];

if ( error )
{
MAAdapterError *adapterError = [ALGoogleMediationAdapter toMaxError: error];
[self log: @"App open ad (%@) failed to load with error: %@", placementIdentifier, adapterError];
[delegate didFailToLoadAppOpenAdWithError: adapterError];
[GADInterstitialAd loadWithAdUnitID: placementIdentifier
request: request
completionHandler:^(GADInterstitialAd *_Nullable interstitialAd, NSError *_Nullable error) {

return;
}

if ( !appOpenAd )
{
[self log: @"App open ad (%@) failed to load: ad is nil", placementIdentifier];
[delegate didFailToLoadAppOpenAdWithError: MAAdapterError.adNotReady];
if ( error )
{
MAAdapterError *adapterError = [ALGoogleMediationAdapter toMaxError: error];
[self log: @"App open interstitial ad (%@) failed to load with error: %@", placementIdentifier, adapterError];
[delegate didFailToLoadAppOpenAdWithError: adapterError];

return;
}

return;
}

[self log: @"App open ad loaded: %@", placementIdentifier];

self.appOpenAd = appOpenAd;
self.appOpenDelegate = [[ALGoogleAppOpenDelegate alloc] initWithParentAdapter: self
placementIdentifier: placementIdentifier
andNotify: delegate];
self.appOpenAd.fullScreenContentDelegate = self.appOpenDelegate;
if ( !interstitialAd )
{
[self log: @"App open interstitial ad (%@) failed to load: ad is nil", placementIdentifier];
[delegate didFailToDisplayAppOpenAdWithError: MAAdapterError.adNotReady];

return;
}

[self log: @"App open interstitial ad loaded: %@", placementIdentifier];

self.appOpenInterstitialAd = interstitialAd;
self.appOpenInterstitialAdDelegate = [[ALGoogleAppOpenDelegate alloc] initWithParentAdapter: self
placementIdentifier: placementIdentifier
andNotify: delegate];
self.appOpenInterstitialAd.fullScreenContentDelegate = self.appOpenInterstitialAdDelegate;

NSString *responseId = self.appOpenInterstitialAd.responseInfo.responseIdentifier;
if ( [responseId al_isValidString] )
{
[delegate didLoadAppOpenAdWithExtraInfo: @{@"creative_id" : responseId}];
}
else
{
[delegate didLoadAppOpenAd];
}
}];
}
else
{
GADRequest *request = [self createAdRequestForBiddingAd: isBiddingAd
adFormat: MAAdFormat.appOpen
withParameters: parameters];
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;

NSString *responseId = self.appOpenAd.responseInfo.responseIdentifier;
if ( [responseId al_isValidString] )
{
[delegate didLoadAppOpenAdWithExtraInfo: @{@"creative_id" : responseId}];
}
else
{
[delegate didLoadAppOpenAd];
}
}];
[GADAppOpenAd loadWithAdUnitID: placementIdentifier
request: request
orientation: orientation
completionHandler:^(GADAppOpenAd *_Nullable appOpenAd, NSError *_Nullable error) {

if ( error )
{
MAAdapterError *adapterError = [ALGoogleMediationAdapter toMaxError: error];
[self log: @"App open ad (%@) failed to load with error: %@", placementIdentifier, adapterError];
[delegate didFailToLoadAppOpenAdWithError: adapterError];

return;
}

if ( !appOpenAd )
{
[self log: @"App open ad (%@) failed to load: ad is nil", placementIdentifier];
[delegate didFailToLoadAppOpenAdWithError: MAAdapterError.adNotReady];

return;
}

[self log: @"App open ad loaded: %@", placementIdentifier];

self.appOpenAd = appOpenAd;
self.appOpenDelegate = [[ALGoogleAppOpenDelegate alloc] initWithParentAdapter: self
placementIdentifier: placementIdentifier
andNotify: delegate];
self.appOpenAd.fullScreenContentDelegate = self.appOpenDelegate;

NSString *responseId = self.appOpenAd.responseInfo.responseIdentifier;
if ( [responseId al_isValidString] )
{
[delegate didLoadAppOpenAdWithExtraInfo: @{@"creative_id" : responseId}];
}
else
{
[delegate didLoadAppOpenAd];
}
}];
}
}

- (void)showAppOpenAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MAAppOpenAdapterDelegateTemp>)delegate
{
NSString *placementIdentifier = parameters.thirdPartyAdPlacementIdentifier;
[self log: @"Showing app open ad: %@...", placementIdentifier];
BOOL isInterstitial = [parameters.serverParameters al_boolForKey: @"is_inter_placement"];
[self log: @"Showing app open %@ad: %@...", ( isInterstitial ? @"interstitial " : @"" ), placementIdentifier];

if ( self.appOpenAd )
if ( self.appOpenInterstitialAd )
{
UIViewController *presentingViewController = [self presentingViewControllerForParameters: parameters];
[self.appOpenInterstitialAd presentFromRootViewController: presentingViewController];
}
else if ( self.appOpenAd )
{
UIViewController *presentingViewController = [self presentingViewControllerForParameters: parameters];
[self.appOpenAd presentFromRootViewController: presentingViewController];
Expand Down

0 comments on commit 3808e87

Please sign in to comment.