Skip to main content

Firebase integration

1.Premise

  • Correctly connect to TradPlus SDK and Firebase SDK *Initialize the SDK and integrate a certain type of advertising
  • TradPlus SDK supports obtaining real-time display advertising revenue. Developers can record the Google Analytics ad_impression event by listening to the impression callback to obtain the ecpm value of the current display ad.

2.Code call

Versionillustrate
V9.5.0.1+Optimized, can be called directly without setting setAdListener synchronously
V8.8.0.1+Provides a global display callback API.
Synchronization requires calling setAdListener of the corresponding type to receive GlobalImpressionListener monitoring.
V8.8.0.1 and below versionsGet ad revenue through ad type's onAdImpression
TradPlusSdk.setGlobalImpressionListener(new GlobalImpressionManager.GlobalImpressionListener() {
@Override
public void onImpressionSuccess(TPAdInfo tpAdInfo) {
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
if (tpAdInfo != null) {
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.AD_PLATFORM, "TradPlus");
bundle.putString(FirebaseAnalytics.Param.AD_SOURCE, tpAdInfo.adSourceName);
bundle.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
bundle.putDouble(FirebaseAnalytics.Param.VALUE, tpAdInfo.ecpm/1000);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.AD_IMPRESSION, bundle);
}
}
});

3. Others

  • When introducing Firebase and Google AdMob at the same time, the following error may occur:java.lang.NoClassDefFoundError:Failed resolution of:Lcom/google/android/gms/ads/rewarded/RewardedAd,which is caused by the conflict between Firebase and Google AdMob SDK.

  • Solution: Quote firebase to adapt to the version of Goolge Admob, the original play-services-ads annotation

// Version number, just for example, the specific version connected to Firebase must be consistent with the version number recommended by TP Adm
// implementation 'com.google.android.gms:play-services-ads:22.0.0'
implementation 'com.google.firebase:firebase-ads:22.0.0'