Skip to content

Commit fe7f769

Browse files
Chi-AnTaihyochan
authored andcommitted
update Readme
change addAdditionalSuccessPurchaseListenerIOS guide
1 parent 76a1b71 commit fe7f769

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ Once you have called `getProducts()`, and you have a valid response, you can cal
190190

191191
```javascript
192192
try {
193+
if(this.subscription) {
194+
this.subscription.remove();
195+
}
193196
// Will return a purchase object with a receipt which can be used to validate on your server.
194197
const purchase = await RNIap.buyProduct('com.example.coins100');
195198
this.setState({
@@ -198,9 +201,9 @@ Once you have called `getProducts()`, and you have a valid response, you can cal
198201
} catch(err) {
199202
// standardized err.code and err.message available
200203
console.warn(err.code, err.message);
201-
const subscription = RNIap.addAdditionalSuccessPurchaseListenerIOS(async (purchase) => {
204+
this.subscription = RNIap.addAdditionalSuccessPurchaseListenerIOS(async (purchase) => {
202205
this.setState({ receipt: purchase.transactionReceipt }, () => this.goToNext());
203-
subscription.remove();
206+
this.subscription.remove();
204207
});
205208
}
206209
```

0 commit comments

Comments
 (0)