facebook_audience_network icon indicating copy to clipboard operation
facebook_audience_network copied to clipboard

Flutter - Facebook Audience Network Banner Ad Not loading, While Interestitial Ad Working fine

Open fldvlpr opened this issue 11 months ago • 3 comments

Hey Folks,

@dreamsoftin @SachinGanesh

Recently, I was working on one of my mobile app and was trying to add facebook audience network plugin, But there is one strange issue is happening with my mobile app. I'm able to fetch interestitial app for facebook ads while banner ads are not loading in debug and release both mode. Following is my code, I've also cross verified my placement id for banner and interestitial ads.

bool isBannerAdLoaded = false;
  Widget bannerAdWidget = const SizedBox();

  void loadBannerAd() {
    debugPrint('facebook loadBannerAd called');
    bannerAdWidget = FacebookBannerAd(
      placementId: FbAdManager.getBannerAdUnitID(),
      bannerSize: BannerSize.STANDARD,
      listener: (result, value) {
        debugPrint('facebook loadBannerAd listener : ${result.toString()}');
        switch (result) {
          case BannerAdResult.ERROR:
            isBannerAdLoaded = false;
            debugPrint('Error: $value');
            break;
          case BannerAdResult.LOADED:
            setState(() {
              isBannerAdLoaded = true;
            });

            debugPrint('Loaded: $value');
            break;
          case BannerAdResult.CLICKED:
            debugPrint('Clicked: $value');
            break;
          case BannerAdResult.LOGGING_IMPRESSION:
            debugPrint('Logging Impression: $value');
            break;
        }
      },
    );
  }

  @override
  void initState() {
    super.initState();

    loadBannerAd();
  }

  @override
  Widget build(BuildContext context) {
    return isBannerAdLoaded ? bannerAdWidget : const SizedBox();
  }

I'm not getting any errors or logs. I've implemented the facebook ads many times in past. But this kind of issue never happened.

Let me know if there is anything if I'm missing.

Thanks

fldvlpr avatar Mar 05 '24 07:03 fldvlpr

@fldvlpr were you able to solve this?

HussainTaj-W avatar May 29 '24 12:05 HussainTaj-W

@fldvlpr instead of placing it based on a flag, place FacebookBannerAd directly inside build method without if clause and wait for it to load and show.

nooralibutt avatar Aug 06 '24 07:08 nooralibutt

Your problem appears in release mode or debug using testIds?

krrskl avatar Aug 25 '24 20:08 krrskl