From f539d3c6dd22993b8e76ed4a4f15de18f0b1f83d Mon Sep 17 00:00:00 2001 From: "warren@mac-m2" Date: Thu, 24 Aug 2023 00:15:28 +0800 Subject: [PATCH] Revised based on distante feedback https://github.com/capacitor-community/admob/pull/249#discussion_r1295951106 --- ios/Plugin/Banner/BannerExecutor.swift | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ios/Plugin/Banner/BannerExecutor.swift b/ios/Plugin/Banner/BannerExecutor.swift index a94f84d2..669febc0 100644 --- a/ios/Plugin/Banner/BannerExecutor.swift +++ b/ios/Plugin/Banner/BannerExecutor.swift @@ -91,10 +91,8 @@ class BannerExecutor: NSObject, GADBannerViewDelegate { let width = subView.frame.width var height = subView.frame.height // For fixing issue 160 iOs banner overlapping content on iPhone with rounded corners - if let window = UIApplication.shared.keyWindow { - let safeAreaBottom = window.safeAreaInsets.bottom - height = height + safeAreaBottom - } + let safeAreaBottom = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0 + height += safeAreaBottom self.plugin?.notifyListeners(BannerAdPluginEvents.SizeChanged.rawValue, data: [ "width": width, @@ -158,10 +156,8 @@ class BannerExecutor: NSObject, GADBannerViewDelegate { let width = bannerView.frame.width var height = bannerView.frame.height // For fixing issue 160 iOs banner overlapping content on iPhone with rounded corners - if let window = UIApplication.shared.keyWindow { - let safeAreaBottom = window.safeAreaInsets.bottom - height = height + safeAreaBottom - } + let safeAreaBottom = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0 + height += safeAreaBottom self.plugin?.notifyListeners(BannerAdPluginEvents.SizeChanged.rawValue, data: [ "width": width,