我有
BillingFlowParams purchaseParams = BillingFlowParams.newBuilder().setSku(skuId).setType(billingType).setOldSkus(oldSkus).build();
但现在
setSku
setType
setOldSkus
已全部弃用。
我想更新旧代码,而又不发布会与现行和以后的订阅相混淆的更新。 我应该如何正确更新上面的代码?
我目前使用
String myProduct="my_newsweek_1";
标识购买,BillingClient.SkuType.SUBS
标识类型,
而我只是将null
传递给setOldSkus
文档报告
setSku (String sku)
和setType (String type)
已替换为setSkuDetails(SkuDetails)
(此SkuDetails
对象在构造函数中仅接收一个String
作为参数,并抛出JSONException
,因此似乎不适用于旧的String
常量)
和
setOldSkus(ArrayList<String> oldSkus)
已替换为setOldSku(String)
答案 0 :(得分:0)
您需要launchBillingFlow()
的BillingFlowParams。您可以使用自己的json字符串创建SkuDetails,但这不是预期的方式。您应该首先调用querySkuDetailsAsync()
并获取必要的skuDetailsList,然后将其用于launchBillingFlow()
public void querySkuDetailsAsync(@SkuType final String itemType, final List<String> skuList, final SkuDetailsResponseListener listener) {
Runnable queryRequest = new Runnable() {
@Override
public void run() {
// Query the purchase async
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(itemType);
mBillingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) {
//use skuDetails in skuDetailsList
}
});
}
};
executeServiceRequest(queryRequest);
}
public void initiatePurchaseFlow(final SkuDetails skuDetails) {
Runnable purchaseFlowRequest = new Runnable() {
@Override
public void run() {
Log.d(TAG, "Launching in-app purchase flow.");
BillingFlowParams purchaseParams = BillingFlowParams.newBuilder().setSkuDetails(skuDetails).build();
mBillingClient.launchBillingFlow(mActivity, purchaseParams);
}
};
executeServiceRequest(purchaseFlowRequest);
}