React-native-iap: [SOLVED] RNIap.getSubscriptions error : [TypeError: undefined is not an object (evaluating 'RNIapIos.getItems')]

Created on 21 Jun 2018  ·  4Comments  ·  Source: dooboolab/react-native-iap

Version of react-native-iap

1.20

Platforms you faced the error (IOS or Android or both?)

tested on iOS only

Expected behavior

get list of subscriptions

Actual behavior

RNIap.getSubscriptions error : [TypeError: undefined is not an object (evaluating 'RNIapIos.getItems')]

Tested environment (Emulator? Real Device?)

both

Steps to reproduce the behavior

````
const itemSkus = Platform.select({
ios: [
'com.shares.sharesapp', // I also tried ['BASIC', 'CLASSIC', 'MAX', 'PLUS'] ..
],
android: [
'com.shares.sharesapp',
],
});

async componentDidMount() {
try {
await RNIap.prepare();
}
catch (err1) {
console.log("RNIap.prepare error : ", err1);
}
finally {
console.log("finally");
try {
const products = await RNIap.getSubscriptions(itemSkus);
console.log('Subscriptions', products);
}
catch (err) {
console.log("RNIap.getSubscriptions error : ", err);
}
}
}
````
I not able to connect with sandbox account in simulator
capture d ecran 2018-06-20 a 15 37 42

and in real device, having these popup
photo

Here is the list of subscriptions in App Store Connect
capture d ecran 2018-06-20 a 12 42 30

Can someone please help me to setup this in good shape ?

📱 iOS 🙏 help wanted

Most helpful comment

I had to manually install as described...
````
Manual installation
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)

````

All 4 comments

I also tryed with
const purchases = await RNIap.getAvailablePurchases(); console.info('Available purchases :: ', purchases);
result same :
RNIap.getSubscriptions error : [TypeError: undefined is not an object (evaluating 'RNIapIos.getAvailableItems')]

And to change ProductID as "com.shares.sharesapp.basic" in App Store Connect and

const itemSkus = Platform.select({ ios: [ 'com.shares.sharesapp.basic' ],
No more success ...

I had to manually install as described...
````
Manual installation
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)

````

This time after it asked me to connect (disconnect on your real device first), I entered the Sandbox user, I was able to grab the subscription detail 👍
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); } } }
Results :
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", }, ]

FYI, RNIap.getSubscriptions(itemSkus) works also in simulator.

Was this page helpful?
0 / 5 - 0 ratings