Question

requestDateMillis from getCustomerInfo is always stale

  • 22 December 2022
  • 3 replies
  • 41 views

Badge +1

The docs say:

 The SDK will update the cache if it's older than 5 minutes, but only if you call getCustomerInfo()

 

However in my testing, whenever I run the below function, the requestTimeMillis remains stale, even after 5 minutes, and I’ve called `getCustomerInfo()`.

I was under the impression this timestamp would change every 5 mins regardless of purchase, to reflect the getCustomerInfo request. Is that not the case?

import moment from "moment";
import Purchases from "react-native-purchases";

async function logRequestDate() {
const customerInfo = await Purchases.getCustomerInfo();
const { requestDateMillis } = customerInfo;
const lastRequestDateString = moment(requestTimeMillis).format("hh:mm:ssa - DD/MM/YY");
console.log(lastRequestDateString); // eg. "08:30:05pm - 22/12/22"
}

logRequestDate();

 


3 replies

Badge +1

Edit: made a variable name mistake above - but the issue still remains:

import moment from "moment";
import Purchases from "react-native-purchases";

async function logRequestDate() {
const customerInfo = await Purchases.getCustomerInfo();
const { requestDateMillis } = customerInfo;
const lastRequestDateString = moment(requestDateMillis).format("hh:mm:ssa - DD/MM/YY");
console.log(lastRequestDateString); // eg. "08:30:05pm - 22/12/22"
}

logRequestDate();

 

Userlevel 1
Badge +4

Hey Mitch, 

 

Thanks for reaching out! Which version of the SDK are you using? I believe the property you are looking for is requestDate which is in the customerInfo object and would be updated when customerInfo is updated. 

 

CustomerInfo will update on any purchase that is made and whenever getCustomerInfo() is called. The SDK will update the cache if it's older than 5 minutes, but only if you call getCustomerInfo(), make a purchase, or restore purchases, so it's a good idea to call getCustomerInfo() any time a user accesses premium content.

Badge +1

Hi Michael,

I’m currently on “react-native-purchases v5.2.2"

I manually called getCustomerInfo() in my app and logged the result and it gave me a requestDate that was five days stale (2023-01-18T22:10:21Z converts to 09:10:21am - 19/01/23 in my timezone), not five minutes!

Is it possible the server caches every five days by mistake?

Reply