Search in sources :

Example 1 with NativeAdsManager

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

the class NativeAdManager method init.

/**
 * Initialises native ad manager for a given placement id and ads to request.
 * This method is run on the UI thread
 *
 * @param placementId
 * @param adsToRequest
 */
@ReactMethod
public void init(final String placementId, final int adsToRequest) {
    final ReactApplicationContext reactContext = this.getReactApplicationContext();
    UiThreadUtil.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            final NativeAdsManager adsManager = new NativeAdsManager(reactContext, placementId, adsToRequest);
            adsManager.setListener(NativeAdManager.this);
            mAdsManagers.put(placementId, adsManager);
            adsManager.loadAds();
        }
    });
}
Also used : ReactApplicationContext(com.facebook.react.bridge.ReactApplicationContext) NativeAdsManager(com.facebook.ads.NativeAdsManager) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 2 with NativeAdsManager

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

the class NativeAdManager method onAdsLoaded.

/**
 * Called when one of the registered ads managers loads ads. Sends state of all
 * managers back to JS
 */
@Override
public void onAdsLoaded() {
    WritableMap adsManagersState = Arguments.createMap();
    for (String key : mAdsManagers.keySet()) {
        NativeAdsManager adsManager = mAdsManagers.get(key);
        adsManagersState.putBoolean(key, adsManager.isLoaded());
    }
    sendAppEvent("CTKNativeAdsManagersChanged", adsManagersState);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) NativeAdsManager(com.facebook.ads.NativeAdsManager)

Example 3 with NativeAdsManager

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

the class NativeAdViewManager method setAdsManager.

@ReactProp(name = "adsManager")
public void setAdsManager(NativeAdView view, String adsManagerId) {
    NativeAdManager adManager = mReactContext.getNativeModule(NativeAdManager.class);
    NativeAdsManager adsManager = adManager.getFBAdsManager(adsManagerId);
    view.setNativeAd(adsManager.nextNativeAd());
}
Also used : NativeAdsManager(com.facebook.ads.NativeAdsManager) ReactProp(com.facebook.react.uimanager.annotations.ReactProp)

Aggregations

NativeAdsManager (com.facebook.ads.NativeAdsManager)3 ReactApplicationContext (com.facebook.react.bridge.ReactApplicationContext)1 ReactMethod (com.facebook.react.bridge.ReactMethod)1 WritableMap (com.facebook.react.bridge.WritableMap)1 ReactProp (com.facebook.react.uimanager.annotations.ReactProp)1