mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 10:52:16 +03:00
init iap
This commit is contained in:
parent
dd63fe8cca
commit
32ff70365d
@ -20,7 +20,7 @@ const BoostPlaceHolder = () => {
|
||||
{({ isDarkTheme }) => {
|
||||
const color = isDarkTheme ? '#2e3d51' : '#f5f5f5';
|
||||
return (
|
||||
<View style={styles.container} key={'key-' + i.toString()}>
|
||||
<View style={styles.container} key={`key-${i.toString()}`}>
|
||||
<View style={styles.line}>
|
||||
<Placeholder.Box color={color} width={90} height={40} animate="fade" />
|
||||
<View style={styles.paragraphWrapper}>
|
||||
|
@ -25,7 +25,14 @@ class InAppPurchaseContainer extends Component {
|
||||
}
|
||||
|
||||
// Component Life Cycle Functions
|
||||
componentDidMount() {
|
||||
async componentDidMount() {
|
||||
try {
|
||||
await RNIap.initConnection();
|
||||
await RNIap.flushFailedPurchasesCachedAsPendingAndroid();
|
||||
} catch (err) {
|
||||
bugsnagInstance.notify(err);
|
||||
console.warn(err.code, err.message);
|
||||
}
|
||||
this._getItems();
|
||||
this._purchaseUpdatedListener();
|
||||
}
|
||||
@ -40,6 +47,7 @@ class InAppPurchaseContainer extends Component {
|
||||
this.purchaseErrorSubscription.remove();
|
||||
this.purchaseErrorSubscription = null;
|
||||
}
|
||||
RNIap.endConnection();
|
||||
}
|
||||
|
||||
// Component Functions
|
||||
@ -111,16 +119,15 @@ class InAppPurchaseContainer extends Component {
|
||||
|
||||
_getItems = async () => {
|
||||
const { skus } = this.props;
|
||||
|
||||
try {
|
||||
const products = await RNIap.getProducts(skus);
|
||||
|
||||
console.log(products);
|
||||
products.sort((a, b) => parseFloat(a.price) - parseFloat(b.price)).reverse();
|
||||
await this.setState({ productList: products });
|
||||
} catch (err) {
|
||||
bugsnagInstance.notify(err);
|
||||
Alert.alert(
|
||||
`InApp - Connection issue, try again or write to support@ecency.com
|
||||
`InApp - Connection issue
|
||||
${err.message.substr(0, 20)}`,
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user