Question

Cannot override cached user wth new sandbox apple id

  • 24 April 2023
  • 1 reply
  • 32 views

Badge

I have a Flutter app running that uses the RevenueCat SDK.  I install the app on my iPhone and make a purchase which utilizes the devices assigned Apple ID to track purchases.Thus works.

Then, I assign a fresh unused AppStore sandbox userID in Settings/AppStore/SandboxAccount.  When I run the app thru VSCode development tools, the Purchases.configure call accesses the RevenueCat cache for the device Apple ID. It does not recognize that the assignment of a Sandbox ID and running through the development tool invokes a different Apple ID and the cache is invalid.

 

I am trying to use the fact that there is no RevenueCat customer entitlements for my app to recognize a new user, but the return of old invalid cached customer info for a different customer is making tis impossible.

 

I tried using invalidateCache  with this code, but it does not ignore the cache…….

 

static Future<void> configure( ) async {

   if (Platform.isAndroid) {

       configuration = PurchasesConfiguration("public_google_sdk_key");

  }

  else if (Platform.isIOS) {

       configuration = PurchasesConfiguration("appl_JPPnWMZhmzvhIDymZYkXYvWENom");

  }

  await Purchases.configure(configuration);

  Purchases.invalidateCustomerInfoCache();

  offerings = await Purchases.getOfferings();

  await PurchasesAPI.getCustomerInfo(); //get cached customer

}

 

Any ideas on how to avoid using the cache would be appreciated.


1 reply

Userlevel 5
Badge +9

Hello,

Unfortunately there is no way to detect if a user signs in with a different Apple ID. This is a limitation on Apple’s end as they don’t provide any indication that the underlying Apple ID has changed.

As for invalidating the cache, I can explain what’s happening by commenting your code:

static Future<void> configure( ) async {

   if (Platform.isAndroid) {

       configuration = PurchasesConfiguration("public_google_sdk_key");

  }

  else if (Platform.isIOS) {

       configuration = PurchasesConfiguration("appl_JPPnWMZhmzvhIDymZYkXYvWENom");

  }

  await Purchases.configure(configuration);

  // Purchases is configured, immediately make a request to RevenueCat to sync data

  Purchases.invalidateCustomerInfoCache();

  // The data that was just synced is invalidated.

  offerings = await Purchases.getOfferings();

  // offerings retrieved from RevenueCat

  await PurchasesAPI.getCustomerInfo();

  // customer info retrieved from RevenueCat

}

I don’t think invalidating the cache would fix the issue of detecting whether the Apple ID was changed. The debug logs will probably tell a more complete story because you can see exactly what info is being fetched from RevenueCat.

Reply