1.20
仅在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错误:”,错误);
}
}
}
``
我无法连接模拟器中的沙箱帐户
并在实际设备中显示这些弹出窗口
这是App Store Connect中的订阅列表
有人可以帮我设置好状态吗?
我也尝试过
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)也可以在模拟器中使用。
最有用的评论
我必须按照说明手动安装...
``
手动安装
的iOS
``