chirag04 / react-native-in-app-utils

A react-native wrapper for handling in-app payments
MIT License
890 stars 185 forks source link

Loading products don't get back #161

Closed GuillaumeMeignan closed 6 years ago

GuillaumeMeignan commented 6 years ago

Hi everyone,

I'm trying to add in-app purchase to my app. I've already added several products via iTunes connect.

But when I tried to load products, the API doesn't not responding.

Thank you for helping a beginner.

TypeError: undefined is not an object (evaluating 'InAppUtils.loadProducts')

This error is located at: in Purchase (at SceneView.js:31) in SceneView (at CardStack.js:423) in RCTView (at View.js:71) in View (at createAnimatedComponent.js:147) in AnimatedComponent (at Card.js:26) in Card (at PointerEventsContainer.js:55) in Container (at CardStack.js:454) in RCTView (at View.js:71) in View (at CardStack.js:383) in RCTView (at View.js:71) in View (at CardStack.js:382) in CardStack (at CardStackTransitioner.js:97) in RCTView (at View.js:71) in View (at Transitioner.js:192) in Transitioner (at CardStackTransitioner.js:49) in CardStackTransitioner (at StackNavigator.js:60) in Unknown (at createNavigator.js:52) in Navigator (at createNavigationContainer.js:212) in NavigationContainer (at registerRootComponent.js:35) in RootErrorBoundary (at registerRootComponent.js:34) in ExpoRootComponent (at renderApplication.js:35) in RCTView (at View.js:71) in View (at AppContainer.js:102) in RCTView (at View.js:71) in View (at AppContainer.js:122) in AppContainer (at renderApplication.js:34)

import React from 'react'
import { View, Text, NativeModules } from 'react-native'
const { InAppUtils } = NativeModules

export default class Purchase extends React.Component {

  loading () {
    var products = [
      'xx.xxx.xx.xxx',
      'xx.xxx.xx.xxx'
    ];
    InAppUtils.loadProducts(products, (error, products) => {
       console.log(products)
    });
  }

  render() {
    this.loading();
    return (
      <View>
        <Text>Hello World</Text>
      </View>
    );
  }

}
chirag04 commented 6 years ago

make sure in-app native modules is linked properly. Try to link manually(refer readme) if it's not working.

Closing for now. Let me know if you still have a problem

GuillaumeMeignan commented 6 years ago

Hi Chirag,

I have init a second project, whit native code this time (and no CRNA like last time);

I follow the two first steps to link manually the module. cc https://facebook.github.io/react-native/docs/linking-libraries-ios.html

And I have the same error : "TypeError : undefined is not an object (evaluating 'InAppUtils.loadProducts').

Bests regards, Guillaume.

EDIT : I success to link manually. It's works. Thank