nooralibutt / easy-ads

This repo has the integration of AdMob, AppLovin-Max, UnityAds, and Facebook ads.
https://pub.dev/packages/easy_ads_flutter
BSD 3-Clause "New" or "Revised" License
41 stars 20 forks source link

rewarded show and load priority #63

Closed sahab2 closed 1 year ago

sahab2 commented 1 year ago

Hi NoorAli and thanks for your great work for this package. I have a question about the load and show of rewarded ads priority. is there anyway to prioritise AdMob over others for certain Ad type for example AdUnitType.rewarded for both loading an showing the ads, somehow like the SmartBannerAd that has this option?

nooralibutt commented 1 year ago

There is no such thing as of right now but you can use this method.

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

    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);
  }