Question

PurchaseParams.Builder(this, aPackage) usage

  • 21 September 2023
  • 1 reply
  • 122 views

Badge +1

Hello, I just started adding a subscription to an android app using java for the first time.

Following the getting started guide, I got to the “Making a purchase” section. I want to use the code example from this section in my app but there is one parameter I’m not sure where is coming from.

This is the code:

Purchases.getSharedInstance().purchase(
new PurchaseParams.Builder(this, aPackage).build(),
new PurchaseCallback() {
@Override
public void onCompleted(@NonNull StoreTransaction storeTransaction, @NonNull CustomerInfo customerInfo) {
if (customerInfo.getEntitlements().get(<my_entitlement_identifier>).isActive()) {
// Unlock that great "pro" content
}
}

@Override
public void onError(@NonNull PurchasesError purchasesError, boolean b) {
// No purchase
}
}
);

The missing parameter is aPackage in the second line. What should I put there?

Additional info: The app has only one product which is a subscription, it is connected to an entitlement, and there are no offerings.

Thanks.


Reply