Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lc3t35 opened this issue Jun 21, 2018 · 5 comments
Labels
🙏 help wanted Extra attention is needed 📱 iOS Related to iOS

Comments

@lc3t35
Copy link

lc3t35 commented Jun 21, 2018

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 ?

@lc3t35
Copy link
Author

lc3t35 commented Jun 21, 2018

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 ...

@hyochan hyochan added 🙏 help wanted Extra attention is needed 📱 iOS Related to iOS labels Jun 21, 2018
@lc3t35
Copy link
Author

lc3t35 commented Jun 21, 2018

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)

@lc3t35
Copy link
Author

lc3t35 commented Jun 21, 2018

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",
   },
 ]````

@lc3t35 lc3t35 changed the title RNIap.getSubscriptions error : [TypeError: undefined is not an object (evaluating 'RNIapIos.getItems')] [SOLVED] RNIap.getSubscriptions error : [TypeError: undefined is not an object (evaluating 'RNIapIos.getItems')] Jun 21, 2018
@lc3t35 lc3t35 closed this as completed Jun 21, 2018
@lc3t35
Copy link
Author

lc3t35 commented Jun 21, 2018

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

@gurmanpsingh
Copy link

gurmanpsingh commented Sep 8, 2022

In 2022, the products fetch this way:
// simple productIDs without bundle identifier.
let allSkus={
skus:[
'productID1',
'productID2',
]
}

  RNIap.getSubscriptions(allSkus); // to fetch the products
  RNIap.requestSubscription({sku:'productID1'}) // to request the subscription.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙏 help wanted Extra attention is needed 📱 iOS Related to iOS
Projects
None yet
Development

No branches or pull requests

3 participants