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