Tenjin SDK可以获取AppLovin的广告展示层级收入数据,并将收入事件发送至Tenjin。这个集成将把每一次AppLovin广告展示获得的收入数据发送给Tenjin。以下是集成步骤:
- 将最新版本的 AppLovin SDK 添加到应用级的 build.gradle 文件中: https://developers.axon.ai/en/max/android/overview/integration
请确保已安装最新版本的 AppLovin Android SDK(> 10.3.5)。 - 在您的Activity中添加
MaxAdRevenueListener接口,并重写onAdRevenuePaid(MaxAd maxAd) method,将展示级别的收入数据发送至 Tenjin SDK。
Java
public class DemoActivity extends Activity implements MaxAdRevenueListener {
private TenjinSDK tenjinInstance;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initialize Tenjin
tenjinInstance = TenjinSDK.getInstance(this, "<Tenjin API Key>");
// Initialize AppLovin
AppLovinSdk.getInstance(this).setMediationProvider(AppLovinMediationProvider.MAX);
AppLovinSdk.initializeSdk(this);
// AppLovin Banner
initAppLovinBanner();
}
private void initAppLovinBanner() {
MaxAdView adView = new MaxAdView("<Applovin Ad unit ID>", this);
adView.setPlacement("Placement name Banner");
adView.setRevenueListener(this);
// Set the height of the banner ad based on the device type.
final boolean isTablet = AppLovinSdkUtils.isTablet(this);
final int heightPx = AppLovinSdkUtils.dpToPx(this, isTablet ? 90 : 50);
// Banner width must match the screen to be fully functional.
adView.setLayoutParams(
new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, heightPx));
// Need to set the background or background color for banners to be fully functional.
adView.setBackgroundColor(Color.BLACK);
final ViewGroup rootView = findViewById(android.R.id.content);
rootView.addView(adView);
// Load the first ad.
adView.loadAd();
}
@Override
public void onAdRevenuePaid(MaxAd maxAd) {
tenjinInstance.eventAdImpressionAppLovin(maxAd);
}
}