Skip to main content
Question

requestDateMillis from getCustomerInfo is always stale

  • Dec 22, 2022 10:21 PM UTC
  • 4 replies
  • 395 views

Forum|alt.badge.img+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();

 

This post has been closed for comments

4 replies

Forum|alt.badge.img+2
  • Author
  • Member
  • Dec 27, 2022 8:05 PM UTC

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

 


Michael Fogel
Forum|alt.badge.img+6
  • Dedicated Contributor
  • Dec 28, 2022 7:06 PM UTC

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.


Forum|alt.badge.img+2
  • Author
  • Member
  • Jan 24, 2023 6:07 AM UTC

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?


Forum|alt.badge.img+2
  • Author
  • Member
  • Jan 30, 2023 2:29 AM UTC

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?