【问题标题】:in_app_purchases using flutterin_app_purchases 使用颤振
【发布时间】:2023-03-30 19:50:01
【问题描述】:

我正在尝试创建一个可以使用 Flutter 处理应用内购买的应用程序。我正在使用 in_app_purchase 0.2.1 插件。我已设法根据需要在 google play 开发人员控制台上设置我的产品,但是当尝试检索它时从应用程序我能够成功连接到商店,但我无法检索我的产品,它总是显示为未找到产品。

我遵循了本教程https://joebirch.co/2019/05/31/adding-in-app-purchases-to-flutter-apps/ 并查看了包文档https://pub.dev/packages/in_app_purchase。 我对产品的 google play 设置如下所示 google play console setup google play console setup2

我正在使用的功能如下所示。

  Future<List<ProductDetails>> retrieveProducts() async {
final bool available = await InAppPurchaseConnection.instance.isAvailable();
if (!available) {
  // Handle store not available
  print("Store Temporarily Unavailable");
  return null;
} else {
  print("Store Temporarily Available");
  const Set<String> _kIds = {'airtime123'};
  final ProductDetailsResponse response =
      await InAppPurchaseConnection.instance.queryProductDetails(_kIds);
  if (response.notFoundIDs.isNotEmpty) {
    print("product not found");
    print(response.notFoundIDs[0]);
    return null;
  }
  print("product found");
  return response.productDetails;
}

}

这是我得到的结果

I/flutter ( 7254): Store Temporarily Available
I/flutter ( 7254): product not found

I/flutter ( 7254): airtime123

【问题讨论】:

  • 同样的问题,你找到解决办法了吗?
  • 不幸的是目前还没有
  • 我面临与 09/2020 相同的问题,对我来说唯一的解决方案是重新加载视图。

标签: flutter google-play google-play-services


【解决方案1】:

您需要使用预留的 SKU 进行测试:android.test.purchased

const Set<String> _kIds = {'android.test.purchased'};
final ProductDetailsResponse response =
    await InAppPurchaseConnection.instance.queryProductDetails(_kIds);

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2019-01-27
  • 1970-01-01
  • 1970-01-01
  • 2021-01-26
  • 1970-01-01
  • 2022-06-14
  • 2020-11-19
  • 2021-01-29
相关资源
最近更新 更多