Skip to content

Commit

Permalink
GoogleAdManager/9.11.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins committed Oct 31, 2022
1 parent 97ab4d2 commit 50d63c8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ s.authors =
'AppLovin Corporation' => '[email protected]'
}
s.name = 'AppLovinMediationGoogleAdManagerAdapter'
s.version = '9.11.0.4'
s.version = '9.11.0.5'
s.platform = :ios, '10.0'
s.summary = 'Google Ad Manager 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 GoogleAdManager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 9.11.0.5
* Fix non-native ad view related buttons becoming unclickable under custom native ad view. Please visit our updated [integration steps](https://dash.applovin.com/documentation/mediation/ios/ad-formats/native-manual#bind-ui-components) for further details.

## 9.11.0.4
* Remove redundant client side check for setting user consent.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "ALGoogleAdManagerMediationAdapter.h"
#import <GoogleMobileAds/GoogleMobileAds.h>

#define ADAPTER_VERSION @"9.11.0.4"
#define ADAPTER_VERSION @"9.11.0.5"

// TODO: Remove when SDK with App Open APIs is released
@protocol MAAppOpenAdapterDelegateTemp<MAAdapterDelegate>
Expand Down Expand Up @@ -87,14 +87,18 @@ @interface ALGoogleAdManagerNativeAdDelegate : NSObject<GADNativeAdLoaderDelegat
@property (nonatomic, weak) ALGoogleAdManagerMediationAdapter *parentAdapter;
@property (nonatomic, strong) NSDictionary<NSString *, id> *serverParameters;
@property (nonatomic, strong) id<MANativeAdAdapterDelegate> delegate;
@property (nonatomic, assign) NSInteger gadNativeAdViewTag;
- (instancetype)initWithParentAdapter:(ALGoogleAdManagerMediationAdapter *)parentAdapter
serverParameters:(NSDictionary<NSString *, id> *)serverParameters
parameters:(id<MAAdapterResponseParameters>)parameters
andNotify:(id<MANativeAdAdapterDelegate>)delegate;
@end

@interface MAGoogleAdManagerNativeAd : MANativeAd
@property (nonatomic, weak) ALGoogleAdManagerMediationAdapter *parentAdapter;
- (instancetype)initWithParentAdapter:(ALGoogleAdManagerMediationAdapter *)parentAdapter builderBlock:(NS_NOESCAPE MANativeAdBuilderBlock)builderBlock;
@property (nonatomic, weak) ALGoogleAdManagerMediationAdapter *parentAdapter;
@property (nonatomic, assign) NSInteger gadNativeAdViewTag;
- (instancetype)initWithParentAdapter:(ALGoogleAdManagerMediationAdapter *)parentAdapter
gadNativeAdViewTag:(NSInteger)gadNativeAdViewTag
builderBlock:(NS_NOESCAPE MANativeAdBuilderBlock)builderBlock;
- (instancetype)initWithFormat:(MAAdFormat *)format builderBlock:(NS_NOESCAPE MANativeAdBuilderBlock)builderBlock NS_UNAVAILABLE;
@end

Expand All @@ -116,6 +120,7 @@ @interface ALGoogleAdManagerMediationAdapter()
@property (nonatomic, strong) ALGoogleAdManagerAdViewDelegate *adViewAdapterDelegate;
@property (nonatomic, strong) ALGoogleAdManagerNativeAdViewAdDelegate *nativeAdViewAdapterDelegate;
@property (nonatomic, strong) ALGoogleAdManagerNativeAdDelegate *nativeAdAdapterDelegate;
@property (nonatomic, assign, getter=isNativeCustomTagValid) BOOL nativeCustomTagValid;

@end

Expand Down Expand Up @@ -175,10 +180,16 @@ - (void)destroy
[self.nativeAd unregisterAdView];
self.nativeAd = nil;

// Remove the view from MANativeAdView in case the publisher decies to re-use the native ad view.
[self.nativeAdView removeFromSuperview];
// Only remove the view when the tag is invalid and hence is not the publisher's own view
if ( ![self isNativeCustomTagValid] )
{
// Remove the view from MANativeAdView in case the publisher decies to re-use the native ad view.
[self.nativeAdView removeFromSuperview];
}

self.nativeAdView = nil;
self.nativeAdViewAdapterDelegate = nil;
self.nativeAdAdapterDelegate = nil;
}

#pragma mark - MAInterstitialAdapter Methods
Expand Down Expand Up @@ -571,7 +582,7 @@ - (void)loadNativeAdForParameters:(nonnull id<MAAdapterResponseParameters>)param
nativeAdImageAdLoaderOptions.shouldRequestMultipleImages = [templateName containsString: @"medium"];

self.nativeAdAdapterDelegate = [[ALGoogleAdManagerNativeAdDelegate alloc] initWithParentAdapter: self
serverParameters: parameters.serverParameters
parameters: parameters
andNotify: delegate];

// Fetching the top view controller needs to be on the main queue
Expand Down Expand Up @@ -1322,15 +1333,25 @@ - (void)nativeAdDidDismissScreen:(GADNativeAd *)nativeAd
@implementation ALGoogleAdManagerNativeAdDelegate

- (instancetype)initWithParentAdapter:(ALGoogleAdManagerMediationAdapter *)parentAdapter
serverParameters:(NSDictionary<NSString *,id> *)serverParameters
andNotify:(id<MANativeAdAdapterDelegate>)delegate
parameters:(id<MAAdapterResponseParameters>)parameters
andNotify:(id<MANativeAdAdapterDelegate>)delegate;
{
self = [super init];
if ( self )
{
self.serverParameters = serverParameters;
self.parentAdapter = parentAdapter;
self.serverParameters = parameters.serverParameters;
self.delegate = delegate;

id gadNativeAdViewTagObj = parameters.localExtraParameters[@"google_native_ad_view_tag"];
if ( [gadNativeAdViewTagObj isKindOfClass: [NSNumber class]] )
{
self.gadNativeAdViewTag = ((NSNumber *) gadNativeAdViewTagObj).integerValue;
}
else
{
self.gadNativeAdViewTag = -1;
}
}
return self;
}
Expand Down Expand Up @@ -1382,7 +1403,9 @@ - (void)adLoader:(GADAdLoader *)adLoader didReceiveNativeAd:(GADNativeAd *)nativ
nativeAd.rootViewController = [ALUtils topViewControllerFromKeyWindow];
});

MANativeAd *maxNativeAd = [[MAGoogleAdManagerNativeAd alloc] initWithParentAdapter: self.parentAdapter builderBlock:^(MANativeAdBuilder *builder) {
MANativeAd *maxNativeAd = [[MAGoogleAdManagerNativeAd alloc] initWithParentAdapter: self.parentAdapter
gadNativeAdViewTag: self.gadNativeAdViewTag
builderBlock:^(MANativeAdBuilder *builder) {

builder.title = nativeAd.headline;
builder.body = nativeAd.body;
Expand Down Expand Up @@ -1461,12 +1484,15 @@ - (void)nativeAdDidDismissScreen:(GADNativeAd *)nativeAd

@implementation MAGoogleAdManagerNativeAd

- (instancetype)initWithParentAdapter:(ALGoogleAdManagerMediationAdapter *)parentAdapter builderBlock:(NS_NOESCAPE MANativeAdBuilderBlock)builderBlock
- (instancetype)initWithParentAdapter:(ALGoogleAdManagerMediationAdapter *)parentAdapter
gadNativeAdViewTag:(NSInteger)gadNativeAdViewTag
builderBlock:(NS_NOESCAPE MANativeAdBuilderBlock)builderBlock
{
self = [super initWithFormat: MAAdFormat.native builderBlock: builderBlock];
if ( self )
{
self.parentAdapter = parentAdapter;
self.gadNativeAdViewTag = gadNativeAdViewTag;
}
return self;
}
Expand All @@ -1480,7 +1506,24 @@ - (void)prepareViewForInteraction:(MANativeAdView *)maxNativeAdView
return;
}

GADNativeAdView *gadNativeAdView = [[GADNativeAdView alloc] init];
// Check if the publisher included Google's `GADNativeAdView`. If we can use an integrated view, Google
// won't need to overlay the view on top of the pub view, causing unrelated buttons to be unclickable
GADNativeAdView *gadNativeAdView = [maxNativeAdView viewWithTag: self.gadNativeAdViewTag];
if ( [gadNativeAdView isKindOfClass: [GADNativeAdView class]] )
{
self.parentAdapter.nativeCustomTagValid = YES;
}
else
{
gadNativeAdView = [[GADNativeAdView alloc] init];

// NOTE: iOS needs order to be maxNativeAdView -> gadNativeAdView in order for assets to be sized correctly
[maxNativeAdView addSubview: gadNativeAdView];

// Pin view in order to make it clickable - this makes views not registered with the native ad view unclickable
[gadNativeAdView al_pinToSuperview];
}

gadNativeAdView.iconView = maxNativeAdView.iconImageView;
gadNativeAdView.headlineView = maxNativeAdView.titleLabel;
gadNativeAdView.bodyView = maxNativeAdView.bodyLabel;
Expand Down Expand Up @@ -1508,12 +1551,6 @@ - (void)prepareViewForInteraction:(MANativeAdView *)maxNativeAdView

gadNativeAdView.nativeAd = self.parentAdapter.nativeAd;

// NOTE: iOS needs order to be maxNativeAdView -> gadNativeAdView in order for assets to be sized correctly
[maxNativeAdView addSubview: gadNativeAdView];

// Pin view in order to make it clickable
[gadNativeAdView al_pinToSuperview];

self.parentAdapter.nativeAdView = gadNativeAdView;
}

Expand Down

0 comments on commit 50d63c8

Please sign in to comment.