Skip to content

Commit

Permalink
Admob SDK v8.0.0
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 424d441043ec3c8d02079ac752ec64e1bce8f895
Author: abhisheksharma <[email protected]>
Date:   Thu Mar 18 17:13:53 2021 +0530

    Updated Admob Pod version

commit 535763e4185793b5b72afeecfc533ce1dede48ca
Author: abhisheksharma <[email protected]>
Date:   Fri Mar 5 01:54:42 2021 +0530

    Updated unit testcase

commit 5e16aad7a44408378dbdb52be6cee97ccd546cc8
Author: abhisheksharma <[email protected]>
Date:   Thu Mar 4 19:23:07 2021 +0530

    Removed ANAdResponseCode

commit a0a22973b9dc3b516f056241a610ea11f1e46c3d
Author: abhisheksharma <[email protected]>
Date:   Thu Mar 4 18:45:21 2021 +0530

    removed unused classes

commit 8d08e9dc25d2bbe0b18a62df4dbddc6d3b1b41a3
Author: abhisheksharma <[email protected]>
Date:   Thu Mar 4 18:43:20 2021 +0530

    added error code

commit 5076e1ff01855add97dba4ed44f04e672976f618
Author: abhisheksharma <[email protected]>
Date:   Fri Feb 26 01:46:41 2021 +0530

    Upgraded google
  • Loading branch information
asharmaa committed Mar 24, 2021
1 parent e84712f commit a77ee7e
Show file tree
Hide file tree
Showing 614 changed files with 31,990 additions and 1,622 deletions.
2 changes: 1 addition & 1 deletion AppNexusSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ DESC

s.subspec 'GoogleAdapter' do |subspec|
subspec.dependency 'AppNexusSDK/AppNexusSDK', "#{s.version}"
subspec.dependency 'Google-Mobile-Ads-SDK', '7.69.0'
subspec.dependency 'Google-Mobile-Ads-SDK', '8.0.0'
subspec.source_files = "mediation/mediatedviews/GoogleAdMob/*.{h,m}"
subspec.public_header_files = "mediation/mediatedviews/GoogleAdMob/ANAdAdapterNativeAdMob.h"
subspec.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/Google-Mobile-Ads-SDK/**' }
Expand Down
81 changes: 15 additions & 66 deletions mediation/mediatedviews/GoogleAdMob/ANAdAdapterBannerAdMob.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#import "ANAdAdapterBannerAdMob.h"
#import "ANAdAdapterBaseDFP.h"

@interface ANAdAdapterBannerAdMob ()
@property (nonatomic, readwrite, strong) GADBannerView *bannerView;
@end
Expand Down Expand Up @@ -56,20 +55,19 @@ - (void)requestBannerAdWithSize:(CGSize)size
UIApplication *application = [UIApplication sharedApplication];
BOOL orientationIsPortrait = UIInterfaceOrientationIsPortrait([application statusBarOrientation]);
if(orientationIsPortrait) {
gadAdSize = kGADAdSizeSmartBannerPortrait;
gadAdSize = GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(size.width);
} else {
gadAdSize = kGADAdSizeSmartBannerLandscape;
gadAdSize = GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(size.height);
}
} else {
gadAdSize = GADAdSizeFromCGSize(size);
}
self.bannerView = [[GADBannerView alloc] initWithAdSize:gadAdSize];

self.bannerView.adUnitID = idString;

self.bannerView.rootViewController = rootViewController;
self.bannerView.delegate = self;
[self.bannerView loadRequest:[self createRequestFromTargetingParameters:targetingParameters]];
self.bannerView.adUnitID = idString;
self.bannerView.rootViewController = rootViewController;
self.bannerView.delegate = self;
[self.bannerView loadRequest:[self createRequestFromTargetingParameters:targetingParameters]];
}

- (GADRequest *)createRequestFromTargetingParameters:(ANTargetingParameters *)targetingParameters {
Expand All @@ -95,83 +93,34 @@ - (AdMobBannerServerSideParameters*) parseServerSide:(NSString*) serverSideParam

#pragma mark GADBannerViewDelegate

- (void)adViewDidReceiveAd:(GADBannerView *)view
- (void)bannerViewDidReceiveAd:(nonnull GADBannerView *)bannerView
{
ANLogDebug(@"AdMob banner did load");
[self.delegate didLoadBannerAd:view];
[self.delegate didLoadBannerAd:bannerView];
}

- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error
- (void)bannerView:(nonnull GADBannerView *)bannerView didFailToReceiveAdWithError:(nonnull NSError *)error
{
ANLogDebug(@"AdMob banner failed to load with error: %@", error);
ANAdResponseCode *code = ANAdResponseCode.INTERNAL_ERROR;

switch (error.code) {
case kGADErrorInvalidRequest:
code = ANAdResponseCode.INVALID_REQUEST;
break;
case kGADErrorNoFill:
code = ANAdResponseCode.UNABLE_TO_FILL;
break;
case kGADErrorNetworkError:
code = ANAdResponseCode.NETWORK_ERROR;
break;
case kGADErrorServerError:
code = ANAdResponseCode.NETWORK_ERROR;
break;
case kGADErrorOSVersionTooLow:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorTimeout:
code = ANAdResponseCode.NETWORK_ERROR;
break;
case kGADErrorAdAlreadyUsed:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorMediationDataError:
code = ANAdResponseCode.INVALID_REQUEST;
break;
case kGADErrorMediationAdapterError:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorMediationInvalidAdSize:
code = ANAdResponseCode.INVALID_REQUEST;
break;
case kGADErrorInternalError:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorInvalidArgument:
code = ANAdResponseCode.INVALID_REQUEST;
break;
default:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
}

[self.delegate didFailToLoadAd:code];
[self.delegate didFailToLoadAd:[ANAdAdapterBaseDFP responseCodeFromRequestError:error]];
}

- (void)adViewWillPresentScreen:(GADBannerView *)adView {
- (void)bannerViewWillPresentScreen:(nonnull GADBannerView *)bannerView{
[self.delegate willPresentAd];
}

- (void)adViewWillDismissScreen:(GADBannerView *)adView {
- (void)bannerViewWillDismissScreen:(nonnull GADBannerView *)bannerView {
[self.delegate willCloseAd];
}

- (void)adViewDidDismissScreen:(GADBannerView *)adView {
- (void)bannerViewDidDismissScreen:(nonnull GADBannerView *)bannerView {
[self.delegate didCloseAd];
}

- (void)adViewWillLeaveApplication:(GADBannerView *)adView {
[self.delegate willLeaveApplication];
}

- (void)dealloc
{
ANLogDebug(@"AdMob banner being destroyed");
self.bannerView.delegate = nil;
self.bannerView = nil;
self.bannerView.delegate = nil;
self.bannerView = nil;
}

@end
82 changes: 17 additions & 65 deletions mediation/mediatedviews/GoogleAdMob/ANAdAdapterBannerDFP.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ @implementation DFPBannerServerSideParameters

@interface ANAdAdapterBannerDFP ()

@property (nonatomic, readwrite, strong) DFPBannerView *dfpBanner;
@property (nonatomic, readwrite, strong) DFPRequest *dfpRequest;
@property (nonatomic, readwrite, strong) GAMBannerView *dfpBanner;
@property (nonatomic, readwrite, strong) GAMRequest *dfpRequest;
@property (nonatomic, readwrite) BOOL secondPriceIsHigher;
@property (nonatomic, readwrite) BOOL secondPriceAvailable;
@property (nonatomic, retain) NSTimer *timer;
Expand Down Expand Up @@ -79,16 +79,14 @@ - (void)requestBannerAdWithSize:(CGSize)size
UIApplication *application = [UIApplication sharedApplication];
BOOL orientationIsPortrait = UIInterfaceOrientationIsPortrait([application statusBarOrientation]);
if(orientationIsPortrait) {
gadAdSize = kGADAdSizeSmartBannerPortrait;
gadAdSize = GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(size.width);
} else {
gadAdSize = kGADAdSizeSmartBannerLandscape;
gadAdSize = GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(size.height);
}
} else {
gadAdSize = GADAdSizeFromCGSize(size);
}


//
self.dfpRequest = [ANAdAdapterBaseDFP dfpRequestFromTargetingParameters:targetingParameters ];
self.secondPriceAvailable = NO;
if (ssparam.secondPrice) {
Expand All @@ -103,9 +101,7 @@ - (void)requestBannerAdWithSize:(CGSize)size
}
}


//
self.dfpBanner = [[DFPBannerView alloc] initWithAdSize:gadAdSize];
self.dfpBanner = [[GAMBannerView alloc] initWithAdSize:gadAdSize];
self.dfpBanner.adUnitID = idString;
self.dfpBanner.rootViewController = rootViewController;
self.dfpBanner.delegate = self;
Expand Down Expand Up @@ -154,8 +150,7 @@ -(void)adReceiveAd{
}

#pragma mark - GADBannerViewDelegate

- (void)adViewDidReceiveAd:(DFPBannerView *)view
- (void)bannerViewDidReceiveAd:(GAMBannerView *)bannerView
{
ANLogDebug(@"DFP banner did load");
if (!self.secondPriceAvailable) {
Expand All @@ -165,69 +160,29 @@ - (void)adViewDidReceiveAd:(DFPBannerView *)view
}
}

- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error
{
- (void)bannerView:(nonnull GADBannerView *)bannerView didFailToReceiveAdWithError:(nonnull NSError *)error{
ANLogDebug(@"DFP banner failed to load with error: %@", [error localizedDescription]);
ANAdResponseCode *code = ANAdResponseCode.INTERNAL_ERROR;

switch (error.code) {
case kGADErrorInvalidRequest:
code = ANAdResponseCode.INVALID_REQUEST;
break;
case kGADErrorNoFill:
code = ANAdResponseCode.UNABLE_TO_FILL;
break;
case kGADErrorNetworkError:
code = ANAdResponseCode.NETWORK_ERROR;
break;
case kGADErrorServerError:
code = ANAdResponseCode.NETWORK_ERROR;
break;
case kGADErrorOSVersionTooLow:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorTimeout:
code = ANAdResponseCode.NETWORK_ERROR;
break;
case kGADErrorAdAlreadyUsed:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorMediationDataError:
code = ANAdResponseCode.INVALID_REQUEST;
break;
case kGADErrorMediationAdapterError:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorMediationInvalidAdSize:
code = ANAdResponseCode.INVALID_REQUEST;
break;
case kGADErrorInternalError:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorInvalidArgument:
code = ANAdResponseCode.INVALID_REQUEST;
break;
default:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
}
[self.timer invalidate];
[self.delegate didFailToLoadAd:code];
[self.delegate didFailToLoadAd:[ANAdAdapterBaseDFP responseCodeFromRequestError:error]];
}

- (void)bannerViewDidRecordImpression:(nonnull GADBannerView *)bannerView{
ANLogDebug(@"DFP banner impression recorded");
}

- (void)adViewWillPresentScreen:(DFPBannerView *)adView {
- (void)bannerViewWillPresentScreen:(GAMBannerView *)adView {
[self.delegate willPresentAd];
}

- (void)adViewWillDismissScreen:(DFPBannerView *)adView {
- (void)bannerViewWillDismissScreen:(nonnull GADBannerView *)bannerView {
[self.delegate willCloseAd];
}

- (void)adViewDidDismissScreen:(DFPBannerView *)adView {
- (void)bannerViewDidDismissScreen:(nonnull GADBannerView *)bannerView {
[self.delegate didCloseAd];
}

- (void)adViewWillLeaveApplication:(DFPBannerView *)adView {
- (void)adViewWillLeaveApplication:(GAMBannerView *)adView {
[self.delegate willLeaveApplication];
}

Expand All @@ -238,12 +193,9 @@ - (void)dealloc
self.dfpBanner = nil;
}




#pragma mark - GADAppEventDelegate

- (void) adView: (DFPBannerView *)banner
- (void) adView: (GAMBannerView *)banner
didReceiveAppEvent: (NSString *)name
withInfo: (NSString *)info
{
Expand Down
5 changes: 2 additions & 3 deletions mediation/mediatedviews/GoogleAdMob/ANAdAdapterBaseDFP.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
@interface ANAdAdapterBaseDFP : NSObject

+ (GADRequest *)googleAdRequestFromTargetingParameters:(ANTargetingParameters *)targetingParameters;
+ (DFPRequest *)dfpRequestFromTargetingParameters:(ANTargetingParameters *)targetingParameters;

+ (ANAdResponseCode *)responseCodeFromRequestError:(GADRequestError *)error;
+ (GAMRequest *)dfpRequestFromTargetingParameters:(ANTargetingParameters *)targetingParameters;
+ (ANAdResponseCode *)responseCodeFromRequestError:(NSError *)error;

@end
41 changes: 25 additions & 16 deletions mediation/mediatedviews/GoogleAdMob/ANAdAdapterBaseDFP.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ + (GADRequest *)googleAdRequestFromTargetingParameters:(ANTargetingParameters *)
return [[self class] completeAdRequest:request fromTargetingParameters:targetingParameters];
}

+ (DFPRequest *)dfpRequestFromTargetingParameters:(ANTargetingParameters *)targetingParameters
+ (GAMRequest *)dfpRequestFromTargetingParameters:(ANTargetingParameters *)targetingParameters
{
DFPRequest *dfpRequest = [DFPRequest request];
return (DFPRequest *)[[self class] completeAdRequest:dfpRequest fromTargetingParameters:targetingParameters];
GAMRequest *dfpRequest = [GAMRequest request];
return (GAMRequest *)[[self class] completeAdRequest:dfpRequest fromTargetingParameters:targetingParameters];
}

+ (GADRequest *)completeAdRequest: (GADRequest *)gadRequest
Expand Down Expand Up @@ -67,44 +67,53 @@ + (GADRequest *)completeAdRequest: (GADRequest *)gadRequest
}


+ (ANAdResponseCode *)responseCodeFromRequestError:(GADRequestError *)error {
+ (ANAdResponseCode *)responseCodeFromRequestError:(NSError *)error {
ANAdResponseCode *code = ANAdResponseCode.INTERNAL_ERROR;

switch (error.code) {
case kGADErrorInvalidRequest:
case GADErrorInvalidRequest:
code = ANAdResponseCode.INVALID_REQUEST;
break;
case kGADErrorNoFill:
case GADErrorNoFill:
code = ANAdResponseCode.UNABLE_TO_FILL;
break;
case kGADErrorNetworkError:
case GADErrorNetworkError:
code = ANAdResponseCode.NETWORK_ERROR;
break;
case kGADErrorServerError:
case GADErrorServerError:
code = ANAdResponseCode.NETWORK_ERROR;
break;
case kGADErrorOSVersionTooLow:
case GADErrorOSVersionTooLow:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorTimeout:
case GADErrorTimeout:
code = ANAdResponseCode.NETWORK_ERROR;
break;
case kGADErrorAdAlreadyUsed:
case GADErrorAdAlreadyUsed:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorMediationDataError:
case GADErrorMediationDataError:
code = ANAdResponseCode.INVALID_REQUEST;
break;
case kGADErrorMediationAdapterError:
case GADErrorMediationAdapterError:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorMediationInvalidAdSize:
case GADErrorMediationInvalidAdSize:
code = ANAdResponseCode.INVALID_REQUEST;
break;
case kGADErrorInternalError:
case GADErrorInternalError:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case kGADErrorInvalidArgument:
case GADErrorInvalidArgument:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case GADErrorReceivedInvalidResponse:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case GADErrorMediationNoFill:
code = ANAdResponseCode.INTERNAL_ERROR;
break;
case GADErrorApplicationIdentifierMissing:
code = ANAdResponseCode.INVALID_REQUEST;
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
#endif
#import <GoogleMobileAds/GoogleMobileAds.h>

@interface ANAdAdapterInterstitialAdMob : NSObject <ANCustomAdapterInterstitial, GADInterstitialDelegate>
@interface ANAdAdapterInterstitialAdMob : NSObject <ANCustomAdapterInterstitial, GADFullScreenContentDelegate>

@end
Loading

0 comments on commit a77ee7e

Please sign in to comment.