Search in sources :

Example 1 with InterstitialAd

use of com.facebook.ads.InterstitialAd in project mopub-android-mediation by mopub.

the class FacebookInterstitial method loadInterstitial.

/**
 * CustomEventInterstitial implementation
 */
@Override
protected void loadInterstitial(final Context context, final CustomEventInterstitialListener customEventInterstitialListener, final Map<String, Object> localExtras, final Map<String, String> serverExtras) {
    MoPubLog.d("Loading Facebook interstitial");
    mInterstitialListener = customEventInterstitialListener;
    final String placementId;
    if (extrasAreValid(serverExtras)) {
        placementId = serverExtras.get(PLACEMENT_ID_KEY);
    } else {
        if (mInterstitialListener != null) {
            mInterstitialListener.onInterstitialFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
        }
        return;
    }
    AdSettings.setMediationService("MOPUB_" + MoPub.SDK_VERSION);
    mFacebookInterstitial = new InterstitialAd(context, placementId);
    mFacebookInterstitial.setAdListener(this);
    mFacebookInterstitial.loadAd();
}
Also used : InterstitialAd(com.facebook.ads.InterstitialAd)

Example 2 with InterstitialAd

use of com.facebook.ads.InterstitialAd in project mopub-android-mediation by mopub.

the class FacebookInterstitial method load.

/**
 * CustomEventInterstitial implementation
 */
@Override
protected void load(@NonNull final Context context, @NonNull final AdData adData) {
    Preconditions.checkNotNull(context);
    Preconditions.checkNotNull(adData);
    if (!AudienceNetworkAds.isInitialized(context)) {
        AudienceNetworkAds.initialize(context);
    }
    setAutomaticImpressionAndClickTracking(false);
    final Map<String, String> extras = adData.getExtras();
    if (extrasAreValid(extras)) {
        mPlacementId = extras.get(PLACEMENT_ID_KEY);
        mFacebookAdapterConfiguration.setCachedInitializationParameters(context, extras);
    } else {
        if (mLoadListener != null) {
            mLoadListener.onAdLoadFailed(MoPubErrorCode.NETWORK_NO_FILL);
            MoPubLog.log(getAdNetworkId(), LOAD_FAILED, ADAPTER_NAME, MoPubErrorCode.NETWORK_NO_FILL.getIntCode(), MoPubErrorCode.NETWORK_NO_FILL);
        }
        return;
    }
    mFacebookInterstitial = new InterstitialAd(context, mPlacementId);
    final String adMarkup = extras.get(DataKeys.ADM_KEY);
    InterstitialAd.InterstitialAdLoadConfigBuilder interstitialLoadAdConfigBuilder = mFacebookInterstitial.buildLoadAdConfig().withAdListener(this);
    if (!TextUtils.isEmpty(adMarkup)) {
        mFacebookInterstitial.loadAd(interstitialLoadAdConfigBuilder.withBid(adMarkup).build());
        MoPubLog.log(getAdNetworkId(), LOAD_ATTEMPTED, ADAPTER_NAME);
    } else {
        mFacebookInterstitial.loadAd(interstitialLoadAdConfigBuilder.build());
        MoPubLog.log(getAdNetworkId(), LOAD_ATTEMPTED, ADAPTER_NAME);
    }
}
Also used : InterstitialAd(com.facebook.ads.InterstitialAd)

Example 3 with InterstitialAd

use of com.facebook.ads.InterstitialAd in project react-native-fbads by callstack.

the class InterstitialAdManager method showAd.

@ReactMethod
public void showAd(String placementId, Promise p) {
    if (mPromise != null) {
        p.reject("E_FAILED_TO_SHOW", "Only one `showAd` can be called at once");
        return;
    }
    ReactApplicationContext reactContext = this.getReactApplicationContext();
    mViewAtOnce = true;
    mPromise = p;
    mInterstitial = new InterstitialAd(reactContext, placementId);
    mInterstitial.loadAd(mInterstitial.buildLoadAdConfig().withAdListener(this).build());
}
Also used : InterstitialAd(com.facebook.ads.InterstitialAd) ReactApplicationContext(com.facebook.react.bridge.ReactApplicationContext) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 4 with InterstitialAd

use of com.facebook.ads.InterstitialAd in project react-native-fbads by callstack.

the class InterstitialAdManager method preloadAd.

@ReactMethod
public void preloadAd(String placementId, Promise p) {
    if (mPromise != null) {
        p.reject("E_FAILED_TO_SHOW", "Only one `preloadAd` can be called at once");
        return;
    }
    ReactApplicationContext reactContext = this.getReactApplicationContext();
    mViewAtOnce = false;
    mPromise = p;
    mInterstitial = new InterstitialAd(reactContext, placementId);
    mInterstitial.loadAd(mInterstitial.buildLoadAdConfig().withAdListener(this).build());
}
Also used : InterstitialAd(com.facebook.ads.InterstitialAd) ReactApplicationContext(com.facebook.react.bridge.ReactApplicationContext) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 5 with InterstitialAd

use of com.facebook.ads.InterstitialAd in project react-native-fbads by callstack.

the class InterstitialAdManager method showAd.

@ReactMethod
public void showAd(String placementId, Promise p) {
    if (mPromise != null) {
        p.reject("E_FAILED_TO_SHOW", "Only one `showAd` can be called at once");
        return;
    }
    ReactApplicationContext reactContext = this.getReactApplicationContext();
    mPromise = p;
    mInterstitial = new InterstitialAd(reactContext, placementId);
    mInterstitial.setAdListener(this);
    mInterstitial.loadAd();
}
Also used : InterstitialAd(com.facebook.ads.InterstitialAd) ReactApplicationContext(com.facebook.react.bridge.ReactApplicationContext) ReactMethod(com.facebook.react.bridge.ReactMethod)

Aggregations

InterstitialAd (com.facebook.ads.InterstitialAd)6 ReactApplicationContext (com.facebook.react.bridge.ReactApplicationContext)4 ReactMethod (com.facebook.react.bridge.ReactMethod)4