nooralibutt/easy-ads

Set priority for Interstitial/Rewarded Ad

Closed this issue · 1 comments

Omi231 commented

Hi, first of all felt proud that fellow pakistanis are maintaining such useful packages and contributing to open source code.

My problem is I want to prioritize Interstitial/rewarded ads same as like you have added the ability of smart banner which works in a waterfall manner.

I want to prioritize Meta Audience network first and if audience network interstitial ad is not available then show applovin or next network's ad. Right now it is showing me random video ad, whichever is available and ready.

Thanks.

@Omi231
you can easily implement priority based ad, let me send you a code snippet:

bool showPriorityInterstitial() {
    const list = [
      AdNetwork.admob,
      AdNetwork.facebook,
      AdNetwork.unity,
      AdNetwork.appLovin,
      AdNetwork.any
    ];

    for (int i = 0; i < list.length; i++) {
      if (list[i] == AdNetwork.facebook) {
        if (EasyAds.instance.showAd(AdUnitType.interstitial,
            adNetwork: AdNetwork.facebook)) return true;
      } else if (list[i] == AdNetwork.unity) {
        if (EasyAds.instance.showAd(AdUnitType.interstitial,
            adNetwork: AdNetwork.unity)) return true;
      } else if (list[i] == AdNetwork.appLovin) {
        if (EasyAds.instance.showAd(AdUnitType.interstitial,
            adNetwork: AdNetwork.appLovin)) return true;
      } else if (list[i] == AdNetwork.admob) {
        if (EasyAds.instance.showAd(AdUnitType.interstitial,
            adNetwork: AdNetwork.admob)) return true;
      }
    }

    return EasyAds.instance.showAd(AdUnitType.interstitial);
  }