Question

requestDateMillis from getCustomerInfo is always stale

  • 22 December 2022
  • 4 replies
  • 97 views

Badge +2

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();

 


4 replies

Badge +2

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 3
Badge +6

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 +2

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?

Badge +2

Update: I’ve run getCustomerInfo() again today on my iPhone and I’m still getting the exact same stale requestDate. I’ve not hit the purchase or restore endpoints since that date, only getCustomerInfo.

 

I have to assume what’s documented isn’t actually what’s happening based on my testing:

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

 

I’m finding that requestDate updating only applies when a purchase or restore is made, and isn’t affected at all by a manual getCustomerInfo call. Is this a bug?

Reply