2

It is the first time that I use react-native-iap in my project. I installed the library without any problems. I have a few questions.

  1. My code block is below for a single product purchase. Is this usage right now?
import * as RNIap from 'react-native-iap';

const itemSkus = Platform.select({
    ios: ['stackoverflow_ex'],
    android: ['stackoverflow_ex']
});

export default class Buy extends Component {

    state= {
        products:[],
        count:0
    }

    async componentDidMount() {
        try {
            const products: Product[] = await RNIap.getProducts(itemSkus);
            this.setState({ products });
        } catch(err) {
            console.warn(err); // standardized err.code and err.message available
        }
    }

    requestPurchase = async (sku: string) => {
        try {
            await RNIap.requestPurchase(sku, false);
            this.setState({ count:this.state.count+1 });
        } catch (err) {
            console.warn(err.code, err.message);
        }
    }

    click = () => {
        this.requestPurchase('stackoverflow_ex') 
    }

    render() {
        const {item} = this.props;
        return (
            <TouchableOpacity onPress={() => this.click()} />
        );
    }
}
  1. How do I get a return from the 'RNIap.requestPurchase (sku, false)' function? For example: const result = RNIap.requestPurchase (sku, false);
  2. The above code works to a certain extent for IOS. Clicking 'Apple Home Page' comes to the payment process. Nothing happens after filling it there. Not doing in Count + 1. Is it because it says 'Ready to Submit' next to the product I added to Apple Connect? Will Apple approve this product? Should I wait for him?
  3. Products are coming in iOS. The empty list on Android is returning. Should I upload it to open beta and try it?
1
  • Hello, were you able to get "products" on app side even "Ready to Submit" was written on itunes ? Commented Dec 26, 2020 at 20:54

2 Answers 2

1

For android you need to upload your apk in Google play. if not then you cannot test Google play billing in your application. What you can do is upload the apk and do a release under Internal test track. It will take 2-3 days for the review process. After that you can do the testing.

For more read please check this link

Sign up to request clarification or add additional context in comments.

Comments

0

From the first glance, I would say that at least initConnection is missing. The best way to make sure the code is done correctly check out example in the github: https://github.com/dooboolab/react-native-iap/blob/master/IapExample/App.js

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.