dreamsoftin / facebook_audience_network

Flutter Facebook Audience Network
https://pub.dartlang.org/packages/facebook_audience_network/
MIT License
154 stars 93 forks source link

Need Admob Mediation Here #103

Open asifakhtar98 opened 3 years ago

asifakhtar98 commented 3 years ago

Can i use admob mediation with this facebook ads package?

bdlukaa commented 3 years ago

No. Use google_mobile_ads instead

faizanhub commented 2 years ago

@bdlukaa why cant we use this package for mediation with google admob, I have implemented this package to show ads and now want to implement bidding with google ad mob ?

bdlukaa commented 2 years ago

This app is only for Facebook ads. If you want admob mediation, you obviously have to use the admob package, not facebook

faizanhub commented 2 years ago

I want to show facebook ads in my app and have done successfully using this package, but in facebook business dashboard it it showing that "we do not receive bid requests" and asks to mediate with some platform, so how can I do that with admob or anyother ?

Omi231 commented 2 years ago

I want to show facebook ads in my app and have done successfully using this package, but in facebook business dashboard it it showing that "we do not receive bid requests" and asks to mediate with some platform, so how can I do that with admob or anyother ?

bro have u found some other solution?

faizanhub commented 2 years ago

@Omi231 Yup, have removed this package from my code and used Google Admob ads code and package in place of Facebook, then in the google AdMob mediation tab, I have added Facebook as a mediation group.

Omi231 commented 2 years ago

@FaiJu If tomorrow Admob bans your account will it still show facebook ads or facebook ads will stop as well?

faizanhub commented 2 years ago

They would be stopped because they are dependent on Admob.

Omi231 commented 2 years ago

@FaiJu Admob is notorious in banning accounts, is there some other option I can do?

faizanhub commented 2 years ago

Yeah, My Admob account is also banned, Me also looking for other options.

elgsylvain85 commented 2 years ago

Hello World :)

In my case, I have implemented both plugins and switch inside application

` abstract class AdFactory { static final int ADS_DELAY_TO_RELOAD = 180000; static final AdProvider DEFAULT_ADPROVIDER = AdProvider.FACEBOOK;

static AdFactory _instance;

int adInitialized = 0;
bool test = false;
GameUtility gameUtility = GameUtility();

static _instanceFactory(AdProvider provider) {
  if (AdFactory._instance == null) {
    switch (provider) {
      case AdProvider.ADMOB:
        AdFactory._instance = AdMob();
        break;
      case AdProvider.ADMOB_TEST:
        AdFactory._instance = AdMob();
        AdFactory._instance.test = true;
        break;
      case AdProvider.FACEBOOK:
        AdFactory._instance = FacebookAudience();
        break;
      case AdProvider.FACEBOOK_TEST:
        AdFactory._instance = FacebookAudience();
        AdFactory._instance.test = true;
        break;
      default:
        AdFactory._instance = AdMob();
        // AdsFactory.instance = FacebookAudience();
        break;
    }
  }

  return AdFactory._instance;
}

static void initializeAd() async {
  try {
    GameUtility gameUtility = GameUtility();

    AdProvider adProvider;

    int index = await gameUtility.indexAdProvider();
    if (index != null && index < AdProvider.values.length) {
      adProvider = AdProvider.values[index];
    }

    AdFactory adFactory = AdFactory._instanceFactory(adProvider);
    await adFactory.initialize();
  } catch (error, stackTrace) {
    log(error?.toString(),
        error: error, stackTrace: stackTrace, time: DateTime.now());
  }
}

static void initBannerAd(AdsStateCallBack callBack) async {
  try {
    await AdFactory.initializeAd();
    AdFactory._instance.showMainBanner(callBack);
  } catch (error, stackTrace) {
    log(error?.toString(),
        error: error, stackTrace: stackTrace, time: DateTime.now());

    // re-run [initBannerAd] again if fail

    await Future.delayed(Duration(milliseconds: ADS_DELAY_TO_RELOAD));

    await AdFactory.initBannerAd(callBack);
  }
}

static void initInterstitialAd() {
  try {
    AdFactory._instance.showMainInterstitial();
  } catch (error, stackTrace) {
    log(error?.toString(),
        error: error, stackTrace: stackTrace, time: DateTime.now());

    // just run [initializeAd] if [initInterstitialAd] fail for next time
    AdFactory.initializeAd();
  }
}

static bool initRewardedAd(AdsStateCallBack callBack) {
  try {
    return AdFactory._instance.showMainRewardedAd(callBack);
  } catch (error, stackTrace) {
    log(error?.toString(),
        error: error, stackTrace: stackTrace, time: DateTime.now());

    // just run [initializeAd] if [initRewardedAd] fail for next time
    AdFactory.initializeAd();
    return false;
  }
}

static AdFactory get instance => AdFactory._instance;

void initialize();
void loadMainBanner(AdsStateCallBack callBack);
void showMainBanner(AdsStateCallBack callBack);
void loadMainInterstitial();
bool showMainInterstitial();
void loadMainRewarded(AdsStateCallBack callBack);
bool showMainRewardedAd(AdsStateCallBack callBack);

} `

enum AdProvider{ ADMOB, ADMOB_TEST, FACEBOOK, FACEBOOK_TEST }

The only problem I have is that Facebook Audience Network is requiring Mediation and is not available with current plugin.

regards,