diff --git a/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m b/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m index dd707ac6..e025270f 100644 --- a/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +++ b/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m @@ -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; }