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.
- 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()} />
);
}
}
- How do I get a return from the 'RNIap.requestPurchase (sku, false)' function? For example: const result = RNIap.requestPurchase (sku, false);
- 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?
- Products are coming in iOS. The empty list on Android is returning. Should I upload it to open beta and try it?
For
android
you need to upload yourapk
in Google play. if not then you cannot test Google play billing in your application. What you can do is upload theapk
and do a release underInternal 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