2

I'm using React Native SDK of RevenueCat.

I'm following official example.

I can make purchase on iOS and get You're all set. Your purchase was successful prompt.

Problem is purchaserInfoUpdateListener is never called and purchase always fall to catch block and I cannot verify if purchase has been made successfully in my code.

What could be the problem?

async componentDidMount() {
    try {
     
      this.purchaserInfoUpdateListener = (info) => {
          console.log('purchaserInfoUpdateListener:: ', info )
          checkIfPro(info);
      };
     
      this.shouldPurchasePromoProduct = async deferredPurchase => {
        this.deferredPurchase = deferredPurchase;
      };
     
      Purchases.addPurchaserInfoUpdateListener(this.purchaserInfoUpdateListener);
      Purchases.addShouldPurchasePromoProductListener(this.shouldPurchasePromoProduct);

    } catch (e) {
      console.log("Error handling");
    }
}

async componentWillUnmount() {
    Purchases.removePurchaserInfoUpdateListener(this.purchaserInfoUpdateListener);
    Purchases.removeShouldPurchasePromoProductListener(this.shouldPurchasePromoProduct);
}

 onPress={async () => {
    const aPackage = this.state.offerings.current.availablePackages[0];
    
    try {
      const purchaseMade = await Purchases.purchasePackage(aPackage);
      checkIfPro(purchaseMade); //never called
      console.log('purchaseMade:: ',purchaseMade) //never called
    } catch (e) {
      if (!e.userCancelled) {                        
        console.log(`Error handling ${JSON.stringify(e)}`);
      } else {  
        console.log(`User cancelled ${JSON.stringify(e)}`);
      }
    }
 }}

Logs:

[Purchases] - DEBUG: No cached purchaser info, fetching

[Purchases] - DEBUG: there are no requests currently running, starting request GET 

[Purchases] - DEBUG: GET /v1/subscribers/$RCAnonymousID:f68c1e27ec9548489acd081bbf178ebe

[Purchases] - DEBUG: GET /v1/subscribers/$RCAnonymousID:f68c1e27ec9548489acd081bbf178ebe/offerings

[Purchases] - DEBUG: GET /v1/subscribers/$RCAnonymousID:f68c1e27ec9548489acd081bbf178ebe/offerings 200

[Purchases] - DEBUG: Requesting products with identifiers: {(

[Purchases] - DEBUG: Products request finished

[Purchases] - DEBUG: Valid Products:

[Purchases] - DEBUG: 2567531 - <SKProduct: 0x281753720>

[Purchases] - DEBUG: com.colorfulNightLight.unlockAllFeatures - <SKProduct: 0x281753740>

[Purchases] - DEBUG: Invalid Product Identifiers - (

[Purchases] - DEBUG: 1 completion handlers waiting on products

[Purchases] - DEBUG: GET /v1/subscribers/$RCAnonymousID:f68c1e27ec9548489acd081bbf178ebe 201

[Purchases] - DEBUG: Sending latest purchaser info to delegate

[Purchases] - DEBUG: serial request done: GET /subscribers/$RCAnonymousID%3Af68c1e27ec9548489acd081bbf178ebe, 0 requests left in the queue

[Purchases] - DEBUG: Vending offerings from cache

[Purchases] - DEBUG: Vending offerings from cache

[Purchases] - DEBUG: Vending purchaserInfo from cache

[Purchases] - DEBUG: Vending purchaserInfo from cache

[Purchases] - DEBUG: applicationDidBecomeActive

[Purchases] - DEBUG: Vending offerings from cache

[Purchases] - DEBUG: Vending offerings from cache

[Purchases] - DEBUG: makePurchase

[Purchases] - DEBUG: makePurchase - com.colorfulNightLight.unlockAllFeatures - Offering: Default

[Purchases] - DEBUG: PaymentQueue updatedTransaction: com.colorfulNightLight.unlockAllFeatures (null) ((null)) (null) - 0

[Purchases] - DEBUG: applicationDidBecomeActive

[Purchases] - DEBUG: applicationDidBecomeActive

[Purchases] - DEBUG: PaymentQueue updatedTransaction: com.colorfulNightLight.unlockAllFeatures 4 ((null)) 0 - 1

[Purchases] - DEBUG: Loaded receipt from file:///private/var/mobile/Containers/Data/Application/3C217C29-CDCE-4EBF-966C-
7ADB8B64CF1C/StoreKit/sandboxReceipt

[Purchases] - INFO: found 0 unsynced attributes for appUserID: $RCAnonymousID:f68c1e27ec9548489acd081bbf178ebe

[Purchases] - DEBUG: there are no requests currently running, starting request POST /receipts

[Purchases] - DEBUG: POST /v1/receipts

[Purchases] - DEBUG: POST /v1/receipts 400

[Purchases] - ERROR: The receipt is not valid.

[Purchases] - DEBUG: serial request done: POST /receipts, 0 requests left in the queue

[Purchases] - DEBUG: Finishing com.colorfulNightLight.unlockAllFeatures 4 (0)

[Purchases] - DEBUG: PaymentQueue removedTransaction: com.colorfulNightLight.unlockAllFeatures 4 (0 (null)) (null) - 1

[Purchases] - DEBUG: Vending offerings from cache

[Purchases] - DEBUG: makePurchase

[Purchases] - DEBUG: makePurchase - com.colorfulNightLight.unlockAllFeatures - Offering: Default

[Purchases] - DEBUG: PaymentQueue updatedTransaction: com.colorfulNightLight.unlockAllFeatures (null) ((null)) (null) - 0

[Purchases] - DEBUG: applicationDidBecomeActive

[Purchases] - DEBUG: applicationDidBecomeActive
ilvthsgm
  • 586
  • 1
  • 8
  • 26
  • Did you ever get the purchase info update listener to work? I am having a similar problem in Flutter code. – GrahamD Dec 07 '20 at 07:23
  • 1
    No, unfortunately I couldn't. I have switched to another library. Seems like RevenueCat support team is sleeping. – ilvthsgm Dec 07 '20 at 07:25
  • Ok thanks. Which library? I tried a couple of other packages for Flutter but they don't support subscription processing half as well as RevenueCat does. – GrahamD Dec 07 '20 at 09:03
  • I only have non-consumable product but you right RevenueCat has lot of skills for subscriptions. I'm using `https://github.com/dooboolab/react-native-iap` right now. – ilvthsgm Dec 07 '20 at 09:28

1 Answers1

1

From the logs, you're receiving a 400 error The receipt is not valid. when sending to RevenueCat. Is this happening on the simulator or physical device?

To test on a simulator (iOS 14+), you need to create a StoreKit config in XCode and upload your certificate to RevenueCat: https://docs.revenuecat.com/docs/apple-app-store#ios-14-only-testing-on-the-simulator

On a physical device, you shouldn't have to do any additional setup to test purchases.

You may have a corrupted sandbox account as well, you can try creating a new sandbox user in App Store Connect.

enc_life
  • 4,973
  • 1
  • 15
  • 27
  • Thanks for the reply. I tested on both simulator and real device. I created StoreKit config file but there was no mention on docs about uploading certificate to RevenueCat I think it is a new thing. Anyway, I switched to another library. I will try it If I switch back to RevenueCat in the future. – ilvthsgm Dec 08 '20 at 13:18