Question

How to Get an Apple product from a SKU using react native?

  • 28 December 2021
  • 2 replies
  • 80 views

Badge

My API get a list of my products (from my server) and display it on app. I'm using revenuecat only to do the subscription.

The problem is that, for each country with his own currency, I need to display the right price, it means, my server doesn't know what is the users country to provide the correct price from Apple.

There is a way on Revenuecat for me send the SKU and get the price based on the user's country?


2 replies

Userlevel 5
Badge +9

Hey @Adriano Carrijo!

There is a method, getProducts, that takes a SKU and returns the product object from the stores which would include localized price.

/**
     * Fetch the product info
     * @param {String[]} productIdentifiers Array of product identifiers
     * @param {String} type Optional type of products to fetch, can be inapp or subs. Subs by default
     * @returns {Promise<PurchasesProduct[]>} A promise containing an array of products. The promise will be rejected 
     * if the products are not properly configured in RevenueCat or if there is another error retrieving them. 
     * Rejections return an error code, and a userInfo object with more information. The promise will also be rejected 
     * if setup has not been called yet.
*/ 

 

I would encourage you to explore using RevenueCat Offerings to offload some of the lifting on your side of fetching product IDs from a server, it’s a pretty flexible setup for most apps and gives you less to worry about. 

Badge

Thank you @ryan 

 

I'll think on your suggestion, I'll need to do a lot of changes on app.

Do you know if there is a way to get the product price using API? I tryed /subscribers/:app_user_id/offerings but it doesn't return the products with prices.

 

Thank you!

 

Reply