From bf8b775108355de3e416abe8326fc0c87da77c0a Mon Sep 17 00:00:00 2001 From: Matt Hilleman Date: Fri, 8 Oct 2021 00:17:48 -0500 Subject: [PATCH 1/3] WIP: Trying to see if we can use the new sizes --- .../FacebookAudienceNetworkBannerAd.swift | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ios/Classes/FacebookAudienceNetworkBannerAd.swift b/ios/Classes/FacebookAudienceNetworkBannerAd.swift index 5aee3b0..bcb3251 100644 --- a/ios/Classes/FacebookAudienceNetworkBannerAd.swift +++ b/ios/Classes/FacebookAudienceNetworkBannerAd.swift @@ -129,11 +129,22 @@ class FacebookAudienceNetworkBannerAdView: NSObject, FlutterPlatformView, FBAdVi ? true : false let valueId: String = existsId ? self.params["id"] as! String : "" - let width: CGFloat = (self.params["width"] != nil) - ? self.params["width"] as! CGFloat : 320.0 let height: CGFloat = (self.params["height"] != nil) ? self.params["height"] as! CGFloat : 50.0 - let adSize: FBAdSize = FBAdSize.init(size: CGSize.init(width: width, height: height)) + var adSize + if (height >= 250.0) + { + adSize = kFBAdSizeHeight250Rectangle + } + else if (height >= 90.0) + { + adSize = kFBAdSizeHeight90Banner + } + else + { + adSize = kFBAdSizeHeight50Banner + } + //let adSize: FBAdSize = FBAdSize.init(size: CGSize.init(width: width, height: height)) if (existsId) { self.bannerAd = FBAdView.init(placementID: valueId, adSize: adSize, rootViewController: UIApplication.shared.keyWindow?.rootViewController) From f1d543c8cbe3ff019c7ebd300d8f41b8bca8865c Mon Sep 17 00:00:00 2001 From: Matthew Hilleman Date: Fri, 8 Oct 2021 00:25:19 -0500 Subject: [PATCH 2/3] Fixed: iOS Banner now fills width --- .../FacebookAudienceNetworkBannerAd.swift | 7 ++---- lib/ad/ad_banner.dart | 23 ++++++++----------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/ios/Classes/FacebookAudienceNetworkBannerAd.swift b/ios/Classes/FacebookAudienceNetworkBannerAd.swift index bcb3251..1ae91a9 100644 --- a/ios/Classes/FacebookAudienceNetworkBannerAd.swift +++ b/ios/Classes/FacebookAudienceNetworkBannerAd.swift @@ -131,7 +131,7 @@ class FacebookAudienceNetworkBannerAdView: NSObject, FlutterPlatformView, FBAdVi ? self.params["id"] as! String : "" let height: CGFloat = (self.params["height"] != nil) ? self.params["height"] as! CGFloat : 50.0 - var adSize + var adSize = kFBAdSizeHeight50Banner if (height >= 250.0) { adSize = kFBAdSizeHeight250Rectangle @@ -140,10 +140,7 @@ class FacebookAudienceNetworkBannerAdView: NSObject, FlutterPlatformView, FBAdVi { adSize = kFBAdSizeHeight90Banner } - else - { - adSize = kFBAdSizeHeight50Banner - } + //let adSize: FBAdSize = FBAdSize.init(size: CGSize.init(width: width, height: height)) if (existsId) { diff --git a/lib/ad/ad_banner.dart b/lib/ad/ad_banner.dart index 16200d5..0c59cdf 100644 --- a/lib/ad/ad_banner.dart +++ b/lib/ad/ad_banner.dart @@ -109,20 +109,15 @@ class _FacebookBannerAdState extends State return Container( height: containerHeight, color: Colors.transparent, - child: Container( - width: widget.bannerSize.width.toDouble(), - child: Center( - child: UiKitView( - viewType: BANNER_AD_CHANNEL, - onPlatformViewCreated: _onBannerAdViewCreated, - creationParams: { - "id": widget.placementId, - "width": widget.bannerSize.width, - "height": widget.bannerSize.height, - }, - creationParamsCodec: StandardMessageCodec(), - ), - ), + child: UiKitView( + viewType: BANNER_AD_CHANNEL, + onPlatformViewCreated: _onBannerAdViewCreated, + creationParams: { + "id": widget.placementId, + "width": widget.bannerSize.width, + "height": widget.bannerSize.height, + }, + creationParamsCodec: StandardMessageCodec(), ), ); } else { From 517b12be85abab83631249fe803b5b3d587f030b Mon Sep 17 00:00:00 2001 From: MattyBoy Date: Fri, 8 Oct 2021 00:41:02 -0500 Subject: [PATCH 3/3] Removed commented code --- ios/Classes/FacebookAudienceNetworkBannerAd.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/ios/Classes/FacebookAudienceNetworkBannerAd.swift b/ios/Classes/FacebookAudienceNetworkBannerAd.swift index 1ae91a9..5ded09e 100644 --- a/ios/Classes/FacebookAudienceNetworkBannerAd.swift +++ b/ios/Classes/FacebookAudienceNetworkBannerAd.swift @@ -141,8 +141,6 @@ class FacebookAudienceNetworkBannerAdView: NSObject, FlutterPlatformView, FBAdVi adSize = kFBAdSizeHeight90Banner } - //let adSize: FBAdSize = FBAdSize.init(size: CGSize.init(width: width, height: height)) - if (existsId) { self.bannerAd = FBAdView.init(placementID: valueId, adSize: adSize, rootViewController: UIApplication.shared.keyWindow?.rootViewController) self.bannerAd.delegate = self