Tenjin SDK có thể thu thập dữ liệu doanh thu ở cấp độ hiển thị quảng cáo từ AppLovin và gửi các sự kiện doanh thu đến Tenjin. Tích hợp này sẽ gửi các sự kiện liên quan đến doanh thu cho mỗi lần hiển thị quảng cáo được phân phối từ AppLovin. Dưới đây là các bước để thực hiện tích hợp:
- Thêm phiên bản mới nhất của SDK AppLovin vào tệp build.gradle ở cấp ứng dụng: https://developers.axon.ai/en/max/android/overview/integration
Vui lòng đảm bảo rằng bạn đã cài đặt phiên bản mới nhất của SDK AppLovin Android (> 10.3.5). - Hãy triển khai
MaxAdRevenueListenertrong hoạt động (activity) của bạn và ghi đè phương thứconAdRevenuePaid(MaxAd maxAd), để bạn có thể gửi dữ liệu doanh thu theo lượt hiển thị đến 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);
}
}