iaphub / react-native-iaphub

The easiest way to implement IAP (In-app purchase) in your React Native app.
https://www.iaphub.com/
MIT License
319 stars 21 forks source link

catch "user_cancelled" #69

Closed dancixx closed 3 years ago

dancixx commented 3 years ago

Hi!

Is there any way to handle event on "user_cancelled" event? When i started a buy request the customer get a loader screen, but he wants to cancel the popped up bottom actionsheet the "user_cancelled" event needs more then 10 seconds. Can I handle this cancel button event with this libarary or should look for something in react-native-iap?

Thx for help.

update: problem solved.

stevenpersia commented 3 years ago

Hi @dancixx ! What did you do to solve your problem ? :smiley:

dancixx commented 3 years ago

Hi @stevenpersia!

I used the errorListener from react-native-iap. Maybe my implementation can be useful to you as well. :)

useEffect(() => {
        RNIap.purchaseErrorListener((event) => {
            console.log(event);
            if (event.code === 'E_USER_CANCELLED') {
                // some logic here;
            }
        });
    }, []);
stevenpersia commented 3 years ago

Thanks for your quick return. It works perfectly. :ok_hand: