【问题标题】:react-native-iap getProducts return empty arrayreact-native-iap getProducts 返回空数组
【发布时间】:2019-12-26 09:25:03
【问题描述】:

我正在使用react-native-iap 进行应用内购买。但是getProducts 方法返回空数组。以下是我为它所做的。

  1. AndroidManifest.xmllike 中插入计费权限
<uses-permission android:name="com.android.vending.BILLING" />
  1. 将此 Android 应用 AAB 上传到alpha 版本,但未发布。
  2. 创建 ID 为 productid1productid2 的产品。 productid1激活的 apkproductid2非激活的
  3. 制作以下代码
import * as RNIap from 'react-native-iap';

const itemSkus = Platform.select({
  ios: ['productid1', 'productid2'],
  android: ['productid1', 'productid2'],
});

...
componentDidMount() {
  RNIap.initConnection().then(conn => {
    // conn is true
    RNIap.getProducts(itemSkus)
      .then(res => {
        // res is []
      })
      .catch(err => {
        // no err
      });
  });
}
...

就像 2018 年 5 月 4 日 hyochan 的 getProducts always returns null 评论一样,我应该等待产品更新吗?或者我的代码有什么问题吗?还是什么?

我的环境是

  • 反应原生:“0.60.5”
  • react-native-iap: "^4.3.3"

【问题讨论】:

  • 你什么时候添加的产品?
  • @GauravRoy 我在 2~3 小时前添加了产品。
  • 等到明天,如果还没有的话。然后再次检查,因为是圣诞节,可能需要一些时间
  • @GauravRoy 那么,有什么方法可以检查产品是否已注册?还是等着看?
  • 我一次花了 1 小时,另一次花了 1 天

标签: react-native


【解决方案1】:

对于那些在 iOS 上遇到这个问题的人,请确保您完成了协议和税收,然后确保将这个 pod 'RNIap', :path =&gt; '../node_modules/react-native-iap' 复制并粘贴到 pod 文件中,然后 cd ios && pod install && cd ..(运行终端命令从应用程序目录)。 我遇到了这个问题,结果我跳过了这些非常重要的步骤。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-12
    • 2021-08-09
    • 2018-03-21
    • 1970-01-01
    • 2020-10-25
    • 2020-09-12
    • 2022-11-17
    相关资源
    最近更新 更多