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?