【发布时间】:2019-12-26 09:25:03
【问题描述】:
我正在使用react-native-iap 进行应用内购买。但是getProducts 方法返回空数组。以下是我为它所做的。
- 在
AndroidManifest.xmllike 中插入计费权限
<uses-permission android:name="com.android.vending.BILLING" />
- 将此 Android 应用 AAB 上传到alpha 版本,但未发布。
- 创建 ID 为
productid1和productid2的产品。productid1是激活的 apk,productid2是非激活的。 - 制作以下代码
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