Получите список продуктов от Huawei В приложении покупки

Итак, я хочу получить список своих продуктов из моей учетной записи разработчика Huawei, я интегрирую sdk, и все в порядке. проблема здесь в этом коде:

      Future<List<ProductInfo>> getConsumableProducts() async {
try {
  ProductInfoReq req = ProductInfoReq(); // The named parameter 'skuIds' is required, but there's no corresponding argument.Try adding the required argument.dartmissing_required_argumentThe named parameter 'priceType' is required, but there's no corresponding argument.Try adding the required argument.dartmissing_required_argument
  req.priceType = IapClient.IN_APP_CONSUMABLE;
  req.skuIds = ["prod_01", "prod_02"];
  ProductInfoResult res = await IapClient.obtainProductInfo(req);
  return res.productInfoList; // A value of type 'List<ProductInfo>?' can't be returned from the method 'getConsumableProducts' because it has a return type of 'Future<List<ProductInfo>>'
} on PlatformException catch (e) {
  log(e.toString());
  return null;
}
}

Я упоминаю о проблемах в коде. PS: я провел поиск и убедился, что это тот же код, который общедоступен

1 ответ

Если вы хотите получить информацию о покупке, вы можете воспользоваться приведенным ниже кодом:

      List<String> productIdList = new ArrayList<>();
// Only those products already configured in AppGallery Connect can be queried.
productIdList.add("ConsumeProduct1001");
ProductInfoReq req = new ProductInfoReq();
// priceType: 0: consumable; 1: non-consumable; 2: subscription
req.setPriceType(0);
req.setProductIds(productIdList);
// Obtain the Activity object that calls the API.
final Activity activity = getActivity();
// Call the obtainProductInfo API to obtain the details of the product configured in AppGallery Connect.
Task<ProductInfoResult> task = Iap.getIapClient(activity).obtainProductInfo(req);

Проверьте здесь для получения дополнительной информации.

Другие вопросы по тегам