diff --git a/GoogleAdManager/AppLovinMediationGoogleAdManagerAdapter.podspec b/GoogleAdManager/AppLovinMediationGoogleAdManagerAdapter.podspec index c679d00d1b..bc6d3820b7 100644 --- a/GoogleAdManager/AppLovinMediationGoogleAdManagerAdapter.podspec +++ b/GoogleAdManager/AppLovinMediationGoogleAdManagerAdapter.podspec @@ -5,7 +5,7 @@ s.authors = 'AppLovin Corporation' => 'devsupport@applovin.com' } 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" diff --git a/GoogleAdManager/CHANGELOG.md b/GoogleAdManager/CHANGELOG.md index b8897df80d..ca35cf381d 100644 --- a/GoogleAdManager/CHANGELOG.md +++ b/GoogleAdManager/CHANGELOG.md @@ -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. diff --git a/GoogleAdManager/GoogleAdManagerAdapter/ALGoogleAdManagerMediationAdapter.m b/GoogleAdManager/GoogleAdManagerAdapter/ALGoogleAdManagerMediationAdapter.m index 1a50a0d134..36ece5ab02 100644 --- a/GoogleAdManager/GoogleAdManagerAdapter/ALGoogleAdManagerMediationAdapter.m +++ b/GoogleAdManager/GoogleAdManagerAdapter/ALGoogleAdManagerMediationAdapter.m @@ -9,7 +9,7 @@ #import "ALGoogleAdManagerMediationAdapter.h" #import -#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 @@ -87,14 +87,18 @@ @interface ALGoogleAdManagerNativeAdDelegate : NSObject *serverParameters; @property (nonatomic, strong) id delegate; +@property (nonatomic, assign) NSInteger gadNativeAdViewTag; - (instancetype)initWithParentAdapter:(ALGoogleAdManagerMediationAdapter *)parentAdapter - serverParameters:(NSDictionary *)serverParameters + parameters:(id)parameters andNotify:(id)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 @@ -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 @@ -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 @@ -571,7 +582,7 @@ - (void)loadNativeAdForParameters:(nonnull id)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 @@ -1322,15 +1333,25 @@ - (void)nativeAdDidDismissScreen:(GADNativeAd *)nativeAd @implementation ALGoogleAdManagerNativeAdDelegate - (instancetype)initWithParentAdapter:(ALGoogleAdManagerMediationAdapter *)parentAdapter - serverParameters:(NSDictionary *)serverParameters - andNotify:(id)delegate + parameters:(id)parameters + andNotify:(id)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; } @@ -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; @@ -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; } @@ -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; @@ -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; }