📜  admost track purchase - Java (1)

📅  最后修改于: 2023-12-03 15:13:15.787000             🧑  作者: Mango

Admost Track Purchase - Java

Admost is an ad mediation platform that allows you to monetize your mobile app through a variety of ad networks. One of the features of Admost is the ability to track in-app purchases. In this tutorial, we will go over how to track in-app purchases using the Admost SDK in Java.

Prerequisites

Before we get started, make sure you have the following:

  • A mobile app integrated with Admost SDK
  • A valid Admost account with access to your app's dashboard
  • A working implementation of in-app purchases in your app
Step 1: Enable Purchase Tracking

In order to track purchases, you need to enable the purchase tracking feature in the Admost dashboard.

  1. Go to your app's dashboard in Admost.
  2. Click on the "Settings" tab.
  3. Scroll down to the "Purchase Tracking" section.
  4. Toggle the "Enable Purchase Tracking" switch to on.
Step 2: Implement Purchase Tracking in Java
  1. Add the following import statement to the top of your Java file:
import admost.sdk.listener.AdMostPurchaseListener;
  1. Implement the AdMostPurchaseListener interface:
public class MainActivity extends AppCompatActivity implements AdMostPurchaseListener {
    ...
}
  1. Override the onPurchaseVerified method to receive the purchase information:
@Override
public void onPurchaseVerified(String productId, String token, String orderId, String purchaseTime, String purchaseState, String developerPayload, String originalJson, String signature) {
    // Handle the purchase information here
}
  1. In your in-app purchase code, call the verifyPurchase method of the Admost SDK:
AdMost.getInstance().verifyPurchase(this, "YOUR_PRODUCT_ID", "YOUR_PURCHASE_TOKEN", this);

Replace "YOUR_PRODUCT_ID" and "YOUR_PURCHASE_TOKEN" with the actual values of your in-app purchase.

Step 3: Test Purchase Tracking

To test purchase tracking, you can make a test purchase in your app, and check the Admost dashboard to see if the purchase is tracked correctly.

Conclusion

In this tutorial, we went over how to track in-app purchases using the Admost SDK in Java. By implementing purchase tracking, you can better monetize your app and optimize your ad strategy.