Skip to content

Commit

Permalink
fix(ios): adaptive banner should take safe areas into account
Browse files Browse the repository at this point in the history
  • Loading branch information
dylancom authored and mikehardy committed Dec 10, 2022
1 parent 4434052 commit c34fe1a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,18 @@ + (GADAdSize)stringToAdSize:(NSString *)value {
} else if ([value isEqualToString:@"LEADERBOARD"]) {
return GADAdSizeLeaderboard;
} else if ([value isEqualToString:@"ADAPTIVE_BANNER"] ||
[value isEqualToString:@"ANCHORED_ADAPTIVE_BANNER"]) {
CGFloat viewWidth = [[UIScreen mainScreen] bounds].size.width;
[value isEqualToString:@"ANCHORED_ADAPTIVE_BANNER"] ||
[value isEqualToString:@"INLINE_ADAPTIVE_BANNER"]) {
CGRect frame = [[UIScreen mainScreen] bounds];
if (@available(iOS 11.0, *)) {
frame =
UIEdgeInsetsInsetRect(frame, [UIApplication sharedApplication].keyWindow.safeAreaInsets);
}
CGFloat viewWidth = frame.size.width;
if ([value isEqualToString:@"INLINE_ADAPTIVE_BANNER"]) {
return GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(viewWidth);
}
return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth);
} else if ([value isEqualToString:@"INLINE_ADAPTIVE_BANNER"]) {
CGFloat viewWidth = [[UIScreen mainScreen] bounds].size.width;
return GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(viewWidth);
} else {
return GADAdSizeBanner;
}
Expand Down

0 comments on commit c34fe1a

Please sign in to comment.