diff --git a/ios/Classes/FacebookAudienceNetworkBannerAd.swift b/ios/Classes/FacebookAudienceNetworkBannerAd.swift index 5aee3b0..5ded09e 100644 --- a/ios/Classes/FacebookAudienceNetworkBannerAd.swift +++ b/ios/Classes/FacebookAudienceNetworkBannerAd.swift @@ -129,12 +129,18 @@ 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 = kFBAdSizeHeight50Banner + if (height >= 250.0) + { + adSize = kFBAdSizeHeight250Rectangle + } + else if (height >= 90.0) + { + adSize = kFBAdSizeHeight90Banner + } + if (existsId) { self.bannerAd = FBAdView.init(placementID: valueId, adSize: adSize, rootViewController: UIApplication.shared.keyWindow?.rootViewController) self.bannerAd.delegate = self 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 {