React-native-iap: [解决] RNIap.getSubscriptions错误:[TypeError:未定义不是对象(正在评估“ RNIapIos.getItems”))

创建于 2018-06-21  ·  4评论  ·  资料来源: dooboolab/react-native-iap

版本的react-native-iap

1.20

您遇到错误的平台(IOS或Android还是两者兼有?)

仅在iOS上测试

预期行为

获取订阅列表

实际行为

RNIap.getSubscriptions错误:[TypeError:未定义不是对象(正在评估“ RNIapIos.getItems”))

经过测试的环境(仿真器?真实设备?)

两个都

重现行为的步骤

``
const itemSkus = Platform.select({
ios:[
'com.shares.sharesapp',//我也尝试过['BASIC','CLASSIC','MAX','PLUS'] ..
],
安卓: [
'com.shares.sharesapp',
],
});

异步componentDidMount(){
尝试{
等待RNIap.prepare();
}
抓(err1){
console.log(“ RNIap.prepare error:”,err1);
}
最后 {
console.log(“ finally”);
尝试{
const products =等待RNIap.getSubscriptions(itemSkus);
console.log('订阅',产品);
}
抓住(错误){
console.log(“ RNIap.getSubscriptions错误:”,错误);
}
}
}
``
我无法连接模拟器中的沙箱帐户
capture d ecran 2018-06-20 a 15 37 42

并在实际设备中显示这些弹出窗口
photo

这是App Store Connect中的订阅列表
capture d ecran 2018-06-20 a 12 42 30

有人可以帮我设置好状态吗?

📱 iOS 🙏 help wanted

最有用的评论

我必须按照说明手动安装...
``
手动安装
的iOS

In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
Go to node_modules ➜ react-native-iap and add RNIap.xcodeproj
In XCode, in the project navigator, select your project. Add libRNIap.a to your project's Build Phases ➜ Link Binary With Libraries
Run your project (Cmd+R)

``

所有4条评论

我也尝试过
const purchases = await RNIap.getAvailablePurchases(); console.info('Available purchases :: ', purchases);
结果相同:
RNIap.getSubscriptions error : [TypeError: undefined is not an object (evaluating 'RNIapIos.getAvailableItems')]

并在App Store Connect中将ProductID更改为“ com.shares.sharesapp.basic”,

const itemSkus = Platform.select({ ios: [ 'com.shares.sharesapp.basic' ],
没有更多的成功...

我必须按照说明手动安装...
``
手动安装
的iOS

In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
Go to node_modules ➜ react-native-iap and add RNIap.xcodeproj
In XCode, in the project navigator, select your project. Add libRNIap.a to your project's Build Phases ➜ Link Binary With Libraries
Run your project (Cmd+R)

``

这次,当它要求我进行连接(首先在您的真实设备上断开连接)之后,我进入了沙箱用户,我能够获取订阅详细信息👍
async componentDidMount() { try { await RNIap.prepare(); } catch (err1) { console.log("RNIap.prepare error : ", err1); } finally { console.log("finally"); try { console.log("itemSkus : ", itemSkus); const products = await RNIap.getSubscriptions(itemSkus); console.log('Subscriptions', products); } catch (err) { console.log("RNIap.getSubscriptions error : ", err); } } }
结果 :
itemSkus : Array [ "com.shares.sharesapp.basic", ] Subscriptions Array [ Object { "currency": "EUR", "description": "***", "localizedPrice": "3,99 €", "price": "3.99", "productId": "com.shares.sharesapp.basic", "title": "Abonnement BASIQUE", "type": "Do not use this. It returned sub only before", }, ]

仅供参考,RNIap.getSubscriptions(itemSkus)也可以在模拟器中使用。

此页面是否有帮助?
0 / 5 - 0 等级