Skip to content

Commit

Permalink
Google/9.11.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins committed Oct 31, 2022
1 parent c7838de commit 97ab4d2
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 19 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.5'
s.version = '9.11.0.6'
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.6
* 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.5
* Fix silent exception thrown during signal collection for app open ads.

Expand Down
15 changes: 11 additions & 4 deletions Google/GoogleAdapter/ALGoogleMediationAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#import "ALGoogleNativeAdViewDelegate.h"
#import "ALGoogleNativeAdDelegate.h"

#define ADAPTER_VERSION @"9.11.0.5"
#define ADAPTER_VERSION @"9.11.0.6"

@interface ALGoogleMediationAdapter()

Expand All @@ -38,6 +38,7 @@ @interface ALGoogleMediationAdapter()
@property (nonatomic, strong) ALGoogleAdViewDelegate *adViewDelegate;
@property (nonatomic, strong) ALGoogleNativeAdViewDelegate *nativeAdViewDelegate;
@property (nonatomic, strong) ALGoogleNativeAdDelegate *nativeAdDelegate;
@property (nonatomic, assign, getter=isNativeCustomTagValid) BOOL nativeCustomTagValid;

@end

Expand Down Expand Up @@ -135,10 +136,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.nativeAdViewDelegate = nil;
self.nativeAdDelegate = nil;
}

#pragma mark - MASignalProvider Methods
Expand Down Expand Up @@ -617,7 +624,7 @@ - (void)loadNativeAdForParameters:(id<MAAdapterResponseParameters>)parameters an
nativeAdImageAdLoaderOptions.shouldRequestMultipleImages = [templateName containsString: @"medium"];

self.nativeAdDelegate = [[ALGoogleNativeAdDelegate alloc] initWithParentAdapter: self
serverParameters: parameters.serverParameters
parameters: parameters
andNotify: delegate];

// Fetching the top view controller needs to be on the main queue
Expand Down
4 changes: 3 additions & 1 deletion Google/GoogleAdapter/ALGoogleNativeAd.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ NS_ASSUME_NONNULL_BEGIN

@interface ALGoogleNativeAd : MANativeAd

- (instancetype)initWithParentAdapter:(ALGoogleMediationAdapter *)parentAdapter builderBlock:(NS_NOESCAPE MANativeAdBuilderBlock)builderBlock;
- (instancetype)initWithParentAdapter:(ALGoogleMediationAdapter *)parentAdapter
gadNativeAdViewTag:(NSInteger)gadNativeAdViewTag
builderBlock:(NS_NOESCAPE MANativeAdBuilderBlock)builderBlock;
- (instancetype)initWithFormat:(MAAdFormat *)format builderBlock:(NS_NOESCAPE MANativeAdBuilderBlock)builderBlock NS_UNAVAILABLE;

@end
Expand Down
34 changes: 25 additions & 9 deletions Google/GoogleAdapter/ALGoogleNativeAd.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@
@interface ALGoogleMediationAdapter()
@property (nonatomic, strong) GADNativeAd *nativeAd;
@property (nonatomic, strong) GADNativeAdView *nativeAdView;
@property (nonatomic, assign, getter=isNativeCustomTagValid) BOOL nativeCustomTagValid;
@end

@interface ALGoogleNativeAd()
@property (nonatomic, weak) ALGoogleMediationAdapter *parentAdapter;
@property (nonatomic, weak) ALGoogleMediationAdapter *parentAdapter;
@property (nonatomic, assign) NSInteger gadNativeAdViewTag;
@end

@implementation ALGoogleNativeAd

- (instancetype)initWithParentAdapter:(ALGoogleMediationAdapter *)parentAdapter builderBlock:(NS_NOESCAPE MANativeAdBuilderBlock)builderBlock
- (instancetype)initWithParentAdapter:(ALGoogleMediationAdapter *)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 @@ -38,7 +43,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 @@ -66,12 +88,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
2 changes: 1 addition & 1 deletion Google/GoogleAdapter/ALGoogleNativeAdDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ALGoogleNativeAdDelegate : NSObject<GADNativeAdLoaderDelegate, GADAdLoaderDelegate, GADNativeAdDelegate>

- (instancetype)initWithParentAdapter:(ALGoogleMediationAdapter *)parentAdapter
serverParameters:(NSDictionary<NSString *, id> *)serverParameters
parameters:(id<MAAdapterResponseParameters>)parameters
andNotify:(id<MANativeAdAdapterDelegate>)delegate;

@end
Expand Down
19 changes: 16 additions & 3 deletions Google/GoogleAdapter/ALGoogleNativeAdDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,31 @@ @interface ALGoogleNativeAdDelegate()
@property (nonatomic, weak) ALGoogleMediationAdapter *parentAdapter;
@property (nonatomic, strong) NSDictionary<NSString *, id> *serverParameters;
@property (nonatomic, strong) id<MANativeAdAdapterDelegate> delegate;
@property (nonatomic, assign) NSInteger gadNativeAdViewTag;
@end

@implementation ALGoogleNativeAdDelegate

- (instancetype)initWithParentAdapter:(ALGoogleMediationAdapter *)parentAdapter
serverParameters:(NSDictionary<NSString *,id> *)serverParameters
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 @@ -82,7 +93,9 @@ - (void)adLoader:(GADAdLoader *)adLoader didReceiveNativeAd:(GADNativeAd *)nativ
nativeAd.rootViewController = [ALUtils topViewControllerFromKeyWindow];
});

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

builder.title = nativeAd.headline;
builder.body = nativeAd.body;
Expand Down

0 comments on commit 97ab4d2

Please sign in to comment.