【发布时间】:2021-03-31 12:40:35
【问题描述】:
我有一个非常基本但令人兴奋的问题,我无法弄清楚。这是这样的:
问题的简短总结
我从 IAP 获得了 receipt 对象,但无法获得 productId 孩子。它返回 undefined ?怎么会发生?收据.productID 返回未定义,尽管收据对象没问题,并且有一个未定义的 productId 子项。它应该完美地返回我'lite_plan',但它返回未定义?
initIAP = () => {
RNIap.initConnection().then(() => {
RNIap.flushFailedPurchasesCachedAsPendingAndroid().catch(() => {
}).then(() => {
console.log('open listener')
this.purchaseUpdateSubscription = purchaseUpdatedListener((purchase: InAppPurchase | SubscriptionPurchase | ProductPurchase ) => {
console.log('purchaseUpdatedListener', purchase);
var receipt = purchase.transactionReceipt;
if (receipt) {
console.log('receipt >> ' + receipt)
console.log('product id >> ' + receipt.productId)
AsyncStorage.setItem('activeplan_local', receipt.productId).then(() => {
.....
控制台输出:
receipt >> {"orderId":"****","packageName":"com.****","productId":"lite_plan","purchaseTime":1617193622753,"purchaseState":0,"purchaseToken":"*****","autoRenewing":true,"acknowledged":false}
product id >> undefined
你能告诉我这个问题吗?
感谢您的支持
【问题讨论】:
标签: javascript react-native react-native-iap