Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return MREC ad size for fluid banner size #71

Open
wants to merge 2 commits into
base: 7.2.x_pre_release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ - (void)getBannerWithSize:(GADAdSize)adSize {
if (!strongConnector || !strongAdapter) {
return;
}

NSLog(@"[FLUID BANNER TESTING - Adapter] Requested banner size received by adapter - width: %f and height: %f", adSize.size.width, adSize.size.height);
_bannerSize = GADMAdapterVungleAdSizeForAdSize(adSize);
if (!IsGADAdSizeValid(_bannerSize)) {
NSString *errorMessage =
Expand Down Expand Up @@ -92,11 +92,21 @@ - (void)loadAd {
[_bannerAd load:nil];
}

- (CGSize)updateBannerViewSizeIfNeeded {
if (GADAdSizeEqualToSize(_bannerSize, GADAdSizeFluid)) {
NSLog(@"[FLUID BANNER TESTING - Adapter] BannerView size has to be updated to allow presentation without errors from VungleSDK");
return CGSizeMake(300, 250);
}
return _bannerSize.size;
}

#pragma mark - VungleBannerDelegate

- (void)bannerAdDidLoad:(nonnull VungleBanner *)banner {
CGSize updatedBannerSize = [self updateBannerViewSizeIfNeeded];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentations of the lines in this method is different. Thanks a lot. :)

_bannerView = [[UIView alloc]
initWithFrame:CGRectMake(0, 0, _bannerSize.size.width, _bannerSize.size.height)];
initWithFrame:CGRectMake(0, 0, updatedBannerSize.width, updatedBannerSize.height)];
NSLog(@"[FLUID BANNER TESTING - Adapter] BannerView size *RIGHT* before SDK present called - width(%f) and height(%f)", _bannerView.frame.size.width, _bannerView.frame.size.height);
[_bannerAd presentOn:_bannerView];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@

const CGSize kVNGBannerShortSize = {300, 50};
GADAdSize GADMAdapterVungleAdSizeForAdSize(GADAdSize adSize) {
// if ((adSize.size.height >= GADAdSizeMediumRectangle.size.height &&
// adSize.size.width >= GADAdSizeMediumRectangle.size.width) ||
// (adSize.size.height == 0 && adSize.size.width == 0)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because above lines are commented out, might we need to update below comment:

// VungleSDK will return MREC ad for 300 X 250 and greater OR
// for 0,0 provided sizes

to

// VungleSDK will return MREC ad for 300 X 250 and greater 

Thanks a lot. :)

if (adSize.size.height >= GADAdSizeMediumRectangle.size.height &&
adSize.size.width >= GADAdSizeMediumRectangle.size.width) {
// VungleSDK will return MREC ad for 300 X 250 and greater OR
// for 0,0 provided sizes
return GADAdSizeMediumRectangle;
}

if ((adSize.size.height == 0 && adSize.size.width == 0)) {
return GADAdSizeFluid;
}

// An array of supported ad sizes.
GADAdSize shortBannerSize = GADAdSizeFromCGSize(kVNGBannerShortSize);
Expand All @@ -54,7 +63,8 @@ GADAdSize GADMAdapterVungleAdSizeForAdSize(GADAdSize adSize) {
}

BannerSize GADMAdapterVungleConvertGADAdSizeToBannerSize(GADAdSize adSize) {
if (GADAdSizeEqualToSize(adSize, GADAdSizeMediumRectangle)) {
if (GADAdSizeEqualToSize(adSize, GADAdSizeMediumRectangle) ||
GADAdSizeEqualToSize(adSize, GADAdSizeFluid)) {
return BannerSizeMrec;
}
if (adSize.size.height == GADAdSizeLeaderboard.size.height) {
Expand Down