I know I can use the following code to query in-app products detail by providing ProductId.
At present, I hope to query all in-app products details, must I provide all ProductId ?
fun queryProductDetails() {
val params = QueryProductDetailsParams.newBuilder()
val productList = mutableListOf<QueryProductDetailsParams.Product>()
for (product in LIST_OF_PRODUCTS) {
productList.add(
QueryProductDetailsParams.Product.newBuilder()
.setProductId(product)
.setProductType(BillingClient.ProductType.INAPP)
.build()
)
}
params.setProductList(productList).let { productDetailsParams ->
billingClient.queryProductDetailsAsync(productDetailsParams.build(), mOnProductDetailsResponse)
}
}
private val LIST_OF_PRODUCTS = listOf(BASIC_SUB, PREMIUM_SUB)
There is no option to query all in-app products without specifying their productId
s and type
(BillingClient.ProductType.INAPP
or BillingClient.ProductType.SUBS
).
If some of the productId
s don't exist or are provided with the wrong type
, you won't receive an error but simply a returned list containing only those product details that match both criteria.
E.g. if BASIC_SUB
and PREMIUM_SUB
from the question are active subscriptions, then you'll receive an empty list when querying with ProductType.INAPP
and a list of 2 product details when querying with ProductType.SUBS
.