dooboolab-community / react-native-iap

In App Purchase module for React Native!
https://react-native-iap.dooboolab.com
MIT License
2.79k stars 638 forks source link

Resubscribe not triggered on iOS #2216

Open ajouve opened 1 year ago

ajouve commented 1 year ago

I am trying to implement a subscription on my app but, it worked great the first time, I called requestSubscription then purchaseUpdatedListener has been triggered.

But days after that, the sandbox subscription has expired and when I am calling requestSubscription then purchaseUpdatedListener is instantly triggered without asking me for the Apple Pay. The purchase variable from purchaseUpdatedListener is my old purchase which has been made days ago

When I verify the receipt from apple server using the /verifyReceipt endpoint the last expire date is 2023-01-22 18:58:28 Etc/GMT and when I am posting we are the 2023-01-25 so the subscription is expired

When I go in my phone parameters in the app store sandbox profile, I can activate again the subscription, but I would like to do it with requestSubscription, this is not really user-friendly to go into parameters, ... Should display the purchase dialog when trying to subscribe back

Environment:

To Reproduce

  1. create an iOS subscription
  2. subscribe to this subscription
  3. Wait for the subscription (this is fast in dev) or unsubscribe from the config
  4. subscribe back
ajouve commented 1 year ago

Found the solution, I had to call clearTransactionIOS before purchase

professorkolik commented 1 year ago

Experiencing the same behavior. Seems finishTransaction doesn't do the job so transaction is not finished. We do clearTransactionIOS though but only when smth went wrong, which I assume correct usage of that method

andresesfm commented 1 year ago

Is this happening only on dev? if finish transaction is not working, please post what the method is returning or if an error is being thrown

rush86999 commented 1 year ago

following

junguksim commented 1 year ago

It seems finishTransaction not working in iOS.

iOS : 16 react-native-iap : 12.7.2 react-native: 0.68.2

        <Button
          title={`Consume all purchases`}
          onPress={async () => {
            // await deepLinkToSubscriptionsIos();
            if (availablePurchases?.length > 0) {
              availablePurchases.forEach(async (purchase: Purchase) => {
                if (purchase.productId) {
                  try {
                    const result = await finishTransaction({
                      purchase,
                      isConsumable: true,
                    });
                    console.log(`purchase result`, result);
                  } catch (e) {
                    console.error(`purchase error!`, e);
                  }
                }
              });
            }
          }}
        />

By this, result are true, but availablePurchases are not cleared.

Relax594 commented 1 year ago

It seems finishTransaction not working in iOS.

iOS : 16 react-native-iap : 12.7.2 react-native: 0.68.2

        <Button
          title={`Consume all purchases`}
          onPress={async () => {
            // await deepLinkToSubscriptionsIos();
            if (availablePurchases?.length > 0) {
              availablePurchases.forEach(async (purchase: Purchase) => {
                if (purchase.productId) {
                  try {
                    const result = await finishTransaction({
                      purchase,
                      isConsumable: true,
                    });
                    console.log(`purchase result`, result);
                  } catch (e) {
                    console.error(`purchase error!`, e);
                  }
                }
              });
            }
          }}
        />

By this, result are true, but availablePurchases are not cleared.

Same here. result is true but when re-initializing IAP on next app start it will automatically purchase the subscription again (without even pressing any button, just because the currentPurchase Effect is triggered). Only on iOS. Android is totally fine and working.

sedot42 commented 1 year ago

Are you on StoreKit 1 or 2? Am seeing the same issue and could only solve it by moving to StoreKit 2.

Relax594 commented 1 year ago

Are you on StoreKit 1 or 2? Am seeing the same issue and could only solve it by moving to StoreKit 2.

SK1, probably need to upgrade yeah

Prathameshlabde commented 1 year ago

https://github.com/dooboolab-community/react-native-iap/issues/2455 Can anyone please suggest on this issue Please ?